summaryrefslogtreecommitdiff
path: root/common.el
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2021-06-05 12:19:59 +0800
committerJSDurand <mmemmew@gmail.com>2021-06-05 12:19:59 +0800
commita94926fb2f18431faf38b21432d3b93c9d2a1d1d (patch)
tree39baa8141bef5513b75c5d9b4dfae1430ebc918e /common.el
parentc4d526d25adf63c6a159096094e18b4c271b8e1c (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.el25
1 files changed, 25 insertions, 0 deletions
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