When you share your 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:
;; 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") ) )
Using those functions, host- or OS-specific settings are done easily:
(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) ) )