summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--emacs/init.el34
1 files changed, 33 insertions, 1 deletions
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)