Nicolas Petton

Nicolas Petton

Web developer, Lisper, Smalltalker & Emacs maniac.

Managing Emacs settings per-computer

Per-computer Emacs settings

June 13, 2014

I use Emacs on all of my machines, being laptops or servers. While my Emacs settings are shared among all of my computers, some of these settings really matter for one specific computer.

For instance, I only read my emails on my main laptop, and I only use my Orgmode files on two computers.

I decided to have some of my settings machine-specific, using the hostname of each computer.

The idea is straightforward, in my init.el, I load an init-HOSTNAME.el file if it is present in the hosts/ subdirectory.

Here's a snippet from my emacs.d configuration:

(defvar host (substring (shell-command-to-string "hostname") 0 -1))
(defvar host-dir (concat "~/.emacs.d/hosts/" host))
(add-to-list 'load-path host-dir)

(let ((init-host-feature (intern (concat "init-" host))))
  (require init-host-feature nil 'noerror))

Another way to split settings is to keep some files private. Some settings might contain sensitive information that you might not want to share along with your Emacs configuration.

To sove this issue I load files from a private directory in ~/.priv/elisp/:

(defvar private-dir "~/.priv/elisp" 
  "Private elisp directory")

(if (file-exists-p private-dir)
    (add-to-list 'load-path private-dir))
comments powered by Disqus