Skip to content

Instantly share code, notes, and snippets.

@sellout
Created January 10, 2023 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sellout/c0d592e8342176c9b971c08dbe78f7db to your computer and use it in GitHub Desktop.
Save sellout/c0d592e8342176c9b971c08dbe78f7db to your computer and use it in GitHub Desktop.
Customizing Emacs without writing to custom-file, useful for organizing customizations in various ways.
;; Adapted from jwiegley/use-package#881 and jwiegley/use-package#899.
(defun custom-pseudo-theme-set-variables (theme &rest args)
"This is a utility for managing custom values “outside of” a theme."
(unless (memq theme custom-known-themes)
(custom-declare-theme theme (custom-make-theme-feature theme)))
(prog1
(apply #'custom-theme-set-variables
theme
(let ((comment-addendum (format "(Customized by %s.)" theme)))
(mapcar
(lambda (def)
(let ((symbol (nth 0 def))
(exp (nth 1 def))
(now (nth 2 def))
(request (nth 3 def))
(comment (nth 4 def)))
(list symbol
exp
now
request
;; TODO: This produces the correct result, but
;; Emacs drops the comment at some point.
(if (stringp comment)
(concat comment " " comment-addendum)
comment-addendum))))
args)))
(enable-theme theme)
(setq custom-enabled-themes (remq theme custom-enabled-themes))))
;;; USAGE EXAMPLE
(custom-pseudo-theme-set-variables
'any-made-up-group-name
'(abbrev-file-name "~/.local/state/emacs/abbrev_defs")
'(auth-sources '("~/.config/emacs/authinfo.gpg")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment