Add association if `key' is not in `alist' and replace all accociation with
single, if there is `key'.
--- a/.emacs-my Tue Oct 13 21:24:58 2020 +0300
+++ b/.emacs-my Sun Nov 01 14:26:50 2020 +0200
@@ -182,6 +182,14 @@
x2
) )
+(defun my-assoc-push (key value alist)
+ "Add association if `key' is not in `alist' and replace all
+accociation with single, if there is `key'."
+ (when (not (symbolp alist)) (error "alist is not a symbol."))
+ (set alist
+ (cons (cons key value)
+ (cl-remove key (symbol-value alist) :key #'car :test #'equal))))
+
(unless (fboundp 'ignore-errors)
(defmacro ignore-errors (&rest body)
"Execute BODY; if an error occurs, return nil.