# HG changeset patch # User Oleksandr Gavenko # Date 1604233610 -7200 # Node ID f6eae5ebf7d9753f590b9e428ff07542c81962bd # Parent 8e99c0b3b772d66e7de728f42bb831291b19d243 Add association if `key' is not in `alist' and replace all accociation with single, if there is `key'. diff -r 8e99c0b3b772 -r f6eae5ebf7d9 .emacs-my --- 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.