From: Morgan Willcock <morgan@ice9.digital>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: 68352@debbugs.gnu.org
Subject: bug#68352: 29.1; gnus-message-citation-mode removes values from font-lock-keywords
Date: Thu, 11 Jan 2024 11:57:36 +0000 [thread overview]
Message-ID: <87o7dskrpr.fsf@ice9.digital> (raw)
In-Reply-To: <87y1cwrg04.fsf@ice9.digital> (Morgan Willcock's message of "Wed, 10 Jan 2024 22:16:27 +0000")
[-- Attachment #1: Type: text/plain, Size: 289 bytes --]
I've attached a patch which is essentially the same as Eric's suggestion
except that, the original comment is kept, the HOW argument of
`font-lock-add-keywords' is set to t, and the code is restructured to
avoid any font-lock changes until `font-lock-mode' is active.
--
Morgan Willcock
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Avoid-font-lock-reset-in-gnus-message-citation-mode.patch --]
[-- Type: text/x-diff, Size: 2565 bytes --]
From 9fa84932aa0ad7c37b20d68ca358ee779d225f09 Mon Sep 17 00:00:00 2001
From: Morgan Willcock <morgan@ice9.digital>
Date: Wed, 10 Jan 2024 21:29:29 +0000
Subject: [PATCH] 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.
---
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 @@ gnus-message-citation-mode
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'."
--
2.39.2
next prev parent reply other threads:[~2024-01-11 11:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-09 20:18 bug#68352: 29.1; gnus-message-citation-mode removes values from font-lock-keywords Morgan Willcock
2024-01-09 21:44 ` Eric Abrahamsen
2024-01-09 22:21 ` Morgan Willcock
2024-01-10 5:25 ` Eric Abrahamsen
2024-01-10 15:21 ` Eric Abrahamsen
2024-01-10 18:51 ` Eric Abrahamsen
2024-01-10 19:20 ` Morgan Willcock
2024-01-10 22:16 ` Morgan Willcock
2024-01-11 11:57 ` Morgan Willcock [this message]
2024-02-11 8:48 ` Eli Zaretskii
2024-02-11 14:49 ` Eric Abrahamsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o7dskrpr.fsf@ice9.digital \
--to=morgan@ice9.digital \
--cc=68352@debbugs.gnu.org \
--cc=eric@ericabrahamsen.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.