Skip to content

Instantly share code, notes, and snippets.

@alex-eg
Created May 7, 2018 22:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-eg/939810504dd02b363d091d16297cb1a2 to your computer and use it in GitHub Desktop.
Save alex-eg/939810504dd02b363d091d16297cb1a2 to your computer and use it in GitHub Desktop.
elisp platform-set-variable
(defvar *var-plist* (list))
(defmacro platform-var (name &rest plist)
(let ((plist-keys (mapcar 'car (seq-partition plist 2)))
(platforms '(:gnu :gnu/linux :gnu/kfreebsd :darwin :ms-dos :windows-nt :cygwin)))
(mapcar (lambda (key)
(when (not (member key platforms))
(error "Platform `%s' doesn't exist. Possible values: `%s'" key platforms)))
plist-keys)
(setq *var-plist* (plist-put *var-plist* name plist))
(values)))
(defmacro platform-get (name)
(let ((platform (intern (string-join (list ":" (symbol-name system-type))))))
(plist-get (plist-get *var-plist* name) platform)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment