From 8f2752f1d619bcbee7ea5960336ba775f09e7a95 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Wed, 15 May 2013 12:24:09 +0100 Subject: Emacs: create systems for getting system location (i.e. work/home) and type (laptop/desktop/server) --- emacs/init.el | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/emacs/init.el b/emacs/init.el index 1b369163..fe051a4d 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -9,6 +9,38 @@ user-full-name "Alan Pearce") (setq custom-file "~/.emacs.d/custom.el") +;;;; Environment & Location + +(defun env/get-location () + "Return the physical location of the system, or `nil' if unknown" + (if (executable-find "netctl") + (catch 'found + (mapc (lambda (line) + (cond + ((string-prefix-p "* home" line) (throw 'found 'home)) + ((string-prefix-p "* work" line) (throw 'found 'work)))) + (process-lines "netctl" "list")) + nil))) + +(defun env/get-system-type () + "Return the type of computer that is running" + (cond + ((string-prefix-p "prefect" system-name) 'desktop) + ((string-prefix-p "server" system-name) 'server) + ((string-prefix-p "sheldon" system-name) 'laptop))) + +(defvar env/location (env/get-location) + "The type of location the system is located +Values: `work', `home'") + +(defvar env/system-type (env/get-system-type) + "The type of computer Emacs is running on +Values: `desktop', `server', `laptop'") + +(defun env/recheck-location () + (interactive) + (setq env/location (env/get-location))) + ;;;; Package Management (setq *elisp-dir* (expand-file-name "elisp/" user-emacs-directory) *custom-dir* (expand-file-name "custom/" user-emacs-directory) @@ -1010,7 +1042,7 @@ Works with: arglist-cont-nonempty, arglist-close." (use-package nxhtml-mode :defer t - :if (boundp '*work*) + :if (eq env/location 'work) :mode (("\\.php\\'" . html-mumamo-mode)) :load-path "nxhtml" :idle (load (expand-file-name "autostart" (expand-file-name "nxhtml" user-emacs-directory)) t) -- cgit 1.4.1