Last active
May 27, 2017 13:54
-
-
Save j8takagi/aef5115954d40341996d7caa5a19b2d3 to your computer and use it in GitHub Desktop.
A Emacs Lisp utilitiy for managing association list (alist), such as default-frame-alist. If key in ALIST, update VALUE of the key. Unless, cons cell (KEY . VALUE) is added
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
(defun update-or-add-alist (alist-var key value) | |
"If KEY in ALIST, update VALUE of the KEY. | |
Unless, cons cell (KEY . VALUE) is added." | |
(interactive) | |
(let (aconscell (alist (symbol-value alist-var))) | |
(if (setq aconscell (assoc key alist)) | |
(unless (equal (cdr aconscell) value) | |
(setf (cdr aconscell) value)) | |
(set alist-var (push (cons key value) alist))) | |
alist)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment