[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 2c887f497c7: Avoid font-lock reset in `gnus-message-citation-mode
From: |
Eric Abrahamsen |
Subject: |
master 2c887f497c7: Avoid font-lock reset in `gnus-message-citation-mode' |
Date: |
Thu, 18 Jan 2024 10:26:28 -0500 (EST) |
branch: master
commit 2c887f497c723c2397888e2f406faa4de3a8208a
Author: Eric Abrahamsen <eric@ericabrahamsen.net>
Commit: Eric Abrahamsen <eric@ericabrahamsen.net>
Avoid font-lock reset in `gnus-message-citation-mode'
* lisp/gnus/gnus-cite.el (gnus-message-citation-mode): Use
`font-lock-add-keywords' and `font-lock-remove-keywords' instead of
modifying font-lock defaults. Make no font-lock changes until
`font-lock-mode' is active.
Thanks to Morgan Willcock
---
lisp/gnus/gnus-cite.el | 36 +++++++++++-------------------------
1 file changed, 11 insertions(+), 25 deletions(-)
diff --git a/lisp/gnus/gnus-cite.el b/lisp/gnus/gnus-cite.el
index 04abdfc0d1b..3fde9baa0fe 100644
--- a/lisp/gnus/gnus-cite.el
+++ b/lisp/gnus/gnus-cite.el
@@ -1122,31 +1122,17 @@ Returns nil if there is no such line before LIMIT, t
otherwise."
When enabled, it automatically turns on `font-lock-mode'."
:lighter ""
(when (derived-mode-p 'message-mode)
- ;; FIXME: Use font-lock-add-keywords!
- (let ((defaults (car font-lock-defaults))
- default) ;; keywords
- (while defaults
- (setq default (if (consp defaults)
- (pop defaults)
- (prog1
- defaults
- (setq defaults nil))))
- (if gnus-message-citation-mode
- ;; `gnus-message-citation-keywords' should be the last
- ;; elements of the keywords because the others are unlikely
- ;; to have the OVERRIDE flags -- XEmacs applies a keyword
- ;; having no OVERRIDE flag to matched text even if it has
- ;; already other faces, while Emacs doesn't.
- (set (make-local-variable default)
- (append (default-value default)
- gnus-message-citation-keywords))
- (kill-local-variable default))))
- ;; Force `font-lock-set-defaults' to update `font-lock-keywords'.
- (setq font-lock-set-defaults nil)
- (font-lock-set-defaults)
- (if font-lock-mode
- (font-lock-flush)
- (gnus-message-citation-mode (font-lock-mode 1)))))
+ (if (not font-lock-mode)
+ (gnus-message-citation-mode (font-lock-mode 1))
+ (if gnus-message-citation-mode
+ ;; `gnus-message-citation-keywords' should be the last
+ ;; elements of the keywords because the others are unlikely
+ ;; to have the OVERRIDE flags -- XEmacs applies a keyword
+ ;; having no OVERRIDE flag to matched text even if it has
+ ;; already other faces, while Emacs doesn't.
+ (font-lock-add-keywords nil gnus-message-citation-keywords t)
+ (font-lock-remove-keywords nil gnus-message-citation-keywords))
+ (font-lock-flush))))
(defun turn-on-gnus-message-citation-mode ()
"Turn on `gnus-message-citation-mode'."
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 2c887f497c7: Avoid font-lock reset in `gnus-message-citation-mode',
Eric Abrahamsen <=