Created
May 7, 2018 22:13
-
-
Save alex-eg/939810504dd02b363d091d16297cb1a2 to your computer and use it in GitHub Desktop.
elisp platform-set-variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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