diff options
author | Alan Pearce | 2013-05-15 12:24:09 +0100 |
---|---|---|
committer | Alan Pearce | 2013-05-15 12:24:09 +0100 |
commit | 8f2752f1d619bcbee7ea5960336ba775f09e7a95 (patch) | |
tree | 6481aaee0cd14faf5f24b2f721cbf925b35cd274 /emacs | |
parent | 40f76781aa679b3fe928a29670d6af072e4c9800 (diff) | |
download | dotfiles-8f2752f1d619bcbee7ea5960336ba775f09e7a95.tar.lz dotfiles-8f2752f1d619bcbee7ea5960336ba775f09e7a95.tar.zst dotfiles-8f2752f1d619bcbee7ea5960336ba775f09e7a95.zip |
Emacs: create systems for getting system location (i.e. work/home) and type (laptop/desktop/server)
Diffstat (limited to 'emacs')
-rw-r--r-- | emacs/init.el | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/emacs/init.el b/emacs/init.el index 1b36916..fe051a4 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) |