To see tags usage please click Raw
button.
I like Emacs. I like working using Emacs. And I have many workstations. I have my personal Macbook, and I have Dell with Windows 10 at work with cyngwin and with linux inside virtualbox.
And I was sick of juggling different versions of init.el
/ init.org
.
I wanted one, simple solution where I could choose which parts of my config are loaded on specific system.
But I didn’t want to abuse system-type
checking. I could use something like:
(use-package foo :if (eq system-type 'darwin))
But this runtime checking felt bad.
I love idea of literate programming, so naturally I used init.org
with tangle combo.
For months I used this:
(defun frondeus/reload-and-tangle-init-org()
"Reloads and tangles Emacs config."
(interactive)
(when (string= buffer-file-name (file-truename (concat user-emacs-directory "init.org")))
(org-babel-tangle)
(byte-compile-file (concat user-emacs-directory "init.el"))
(byte-compile-file (concat user-emacs-directory "windows.el"))
(byte-compile-file (concat user-emacs-directory "osx.el"))
(load (concat user-emacs-directory "init"))))
As you can see I had different files for systems with one shared config inside init.el
.
I used simple fact, that every heading can have own :tangle
property.
Then I had one system-type
check to choose which file should be loaded.
Then one day I came across this simple solution. And I knew I could refactor it to fit my idea.
Tags - that’s my solution. Simple and clean.
If I want to tangle some shared config I just write #+BEGIN_SRC
without any tag.
Like that:
(use-package magit :ensure t)
This config will be tangled only on my Dell.
(use-package omnisharp :ensure t)
This config will be available on linux and cyngwin but not on osx.
(setq user-mail-address "my-email@email.com")
;; Old stuff....
I know my english and my elisp skills are not perfect. If you see I made mistake - please give me feedback.