HuffTheMagicFlagon · 2022-05-19 21:58
I’m returning to Emacs after not having used it for a while and have really been enjoying it. I have two different computers and am syncing my config files between the two. One of them is a high dpi laptop. Is there a way I can share config files but have different font settings per computer? Like with a conditional based on the hostname or something?
franburstall · 2022-05-19 22:39
Sure, towards the end of my config I have
(require (intern (system-name)) nil 'noerror)
which, if `(system-name)` returns "hi-dpi-laptop", will attempt to load `hi-dpi-laptop.el`.
zck · 2022-05-19 22:40
You could use [system-name](https://www.gnu.org/software/emacs/manual/html_node/elisp/System-Environment.html#index-system_002dname) to figure out which computer you're on.
HuffTheMagicFlagon · 2022-05-20 01:15
Beautiful, thanks yall
a-c-d-w · 2022-05-20 14:01
I wrote a little package for this : [machine.el](https://github.com/duckwork/machine.el). It's not really "packaged" or anything, per se, but it works well for me.
Phil-Hudson · 2022-05-21 16:55
Good suggestions already given, built around `(system-name)`. For more sophistication, you might find the more generalized techniques I use helpful:
1. Use symbolic links to make the concrete host config (such as `foo-host.el` and `bar-host.el`) appear under an abstract identity (such as `host.el`) which is always present on all machines. Your init then simply calls `(require 'host)` and the computer's file system resolves this to your specific `foo-host.el`. Note that `foo-host.el` should declare *both* `(provide 'host)` *and* `(provide 'foo-host)`.
2. Use package `initsplit.el` to write out customizations to similarly symlinked custom files: `host-custom.el`, `os-custom.el`, `emacs-version-in-use-custom.el` etc.
3. Keep *all* of the concrete files under version control using git, Mercurial or what have you. Use that version control system to sync your whole `~/.emacs.d/` tree across hosts. Keep *none* of the links pointing to them under version control; those have to be set up once on each host, but that's easy to automate with a shell script.
This approach generalizes well to other cross-cutting abstractions too: operating system, travelling/docked, Emacs version, tty/GUI, etc etc.