diff options
author | JSDurand <mmemmew@gmail.com> | 2021-06-05 12:19:59 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2021-06-05 12:19:59 +0800 |
commit | a94926fb2f18431faf38b21432d3b93c9d2a1d1d (patch) | |
tree | 39baa8141bef5513b75c5d9b4dfae1430ebc918e /common.el | |
parent | c4d526d25adf63c6a159096094e18b4c271b8e1c (diff) |
common: a better face-remap-remove-relative
* common.el (durand-face-remap-remove-relative):
(face-remap-remove-relative): Now uses `remove' to remove elements,
which compares elements by `equal' instead of `eq'.
Diffstat (limited to 'common.el')
-rw-r--r-- | common.el | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -12,6 +12,31 @@ 32) str))))) +;;; A better face-remap-remove-relative + +(defun durand-face-remap-remove-relative (cookie) + "Remove a face remapping previously added by `face-remap-add-relative'. +COOKIE should be the return value from that function. + +Modified by Durand to use `equal' as the comparison function, so +that we are not required to record the objects returned +previously by `face-remap-add-relative', at 2021-06-05." + (let ((remapping (assq (car cookie) face-remapping-alist))) + (when remapping + (let ((updated-entries (remove (cdr cookie) (cdr remapping)))) + (unless (eq updated-entries (cdr remapping)) + (setcdr remapping updated-entries) + (when (or (null updated-entries) + (and (eq (car-safe updated-entries) (car cookie)) + (null (cdr updated-entries)))) + (setq face-remapping-alist + (remove remapping face-remapping-alist)) + ;; Force redisplay of this buffer. + (force-mode-line-update)) + (cdr cookie)))))) + +(advice-add 'face-remap-remove-relative :override 'durand-face-remap-remove-relative) + ;;; jump between the completions buffer and the minibuffer ;;;###autoload |