From a94926fb2f18431faf38b21432d3b93c9d2a1d1d Mon Sep 17 00:00:00 2001 From: JSDurand Date: Sat, 5 Jun 2021 12:19:59 +0800 Subject: 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'. --- common.el | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/common.el b/common.el index 1a062e8..b17787b 100644 --- a/common.el +++ b/common.el @@ -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 -- cgit v1.2.3-18-g5258