CLOSED: [2017-02-11 Sat 18:36] SCHEDULED: <2017-02-11 Sat> :PROPERTIES: :ID: 2017-02-11-my-system-is-foobar :CREATED: [2017-01-16 Mon 22:44] :END: :LOGBOOK: - State "DONE" from "NEXT" [2017-02-11 Sat 18:36] :END: When you share your [[https://github.com/novoid/dot-emacs][Emacs configuration]] between all of your hosts (which you should do!), you might want to do certain things only for specific hosts or for hosts sharing the same operating system. ------------------ I am using following functions that derives operating systems and host names: #+BEGIN_SRC elisp ;; Check if system is Darwin/macOS (defun my-system-type-is-darwin () "Return true if system is darwin-based (Mac OS X)" (string-equal system-type "darwin") ) ;; Check if system is Microsoft Windows (defun my-system-type-is-windows () "Return true if system is Windows-based (at least up to Win7)" (string-equal system-type "windows-nt") ) ;; Check if system is GNU/Linux (defun my-system-type-is-gnu () "Return true if system is GNU/Linux-based" (string-equal system-type "gnu/linux") ) ;; Check if the hostname is mynotebook (defun my-system-is-mynotebook () "Return true if the system we are running on is mynotebook" (or (string-equal system-name "mynotebook") (string-equal system-name "mynotebook.lan") ) ) ;; Check if the hostname is mydesktop (defun my-system-is-mydesktop () "Return true if the system we are running on is mydesktop" (or (string-equal system-name "mydesktop") (string-equal system-name "mydesktop.lan") ) ) #+END_SRC Using those functions, host- or OS-specific settings are done easily: #+BEGIN_SRC elisp (when (my-system-is-mynotebook) (set-face-attribute 'default (selected-frame) :height 110) ) (when (my-system-type-is-windows) (defun my-yank-windows () "yanks from clipboard and replaces typical (list) markup" (interactive) ;;[...] ) ) (use-package elpy :ensure t :if (or (my-system-type-is-gnu) (my-system-is-mynotebook)) :mode ("\\.py\\'" . elpy-mode) :config (when (my-system-type-is-gnu) (elpy-enable) (elpy-use-ipython) ) ) #+END_SRC