GNU bug report logs - #68352
29.1; gnus-message-citation-mode removes values from font-lock-keywords

Previous Next

Package: emacs;

Reported by: Morgan Willcock <morgan <at> ice9.digital>

Date: Tue, 9 Jan 2024 20:20:02 UTC

Severity: normal

Found in version 29.1

Done: Eric Abrahamsen <eric <at> ericabrahamsen.net>

Bug is archived. No further changes may be made.

Full log


Message #17 received at 68352 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Morgan Willcock <morgan <at> ice9.digital>
Cc: 68352 <at> debbugs.gnu.org
Subject: Re: bug#68352: 29.1; gnus-message-citation-mode removes values from
 font-lock-keywords
Date: Wed, 10 Jan 2024 07:21:38 -0800
Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:

> Morgan Willcock <morgan <at> ice9.digital> writes:
>
>> Eric Abrahamsen <eric <at> ericabrahamsen.net> writes:
>>
>>> Morgan Willcock <morgan <at> ice9.digital> writes:
>>>
>>>> When Gnus enables gnus-message-citation-mode in message buffers, as it
>>>> does by default, it calls the function `font-lock-set-defaults' and
>>>> loses any additional font-lock rules which may have been added by global
>>>> minor-modes.
>>>
>>> Thanks for the report. I don't know font locking well enough to know
>>> what the right solution is here. It looks calling `font-lock-flush' will
>>> also end up calling `font-lock-set-defaults' as well, at least with
>>> default values:
>>>
>>> font-lock-flush-function ->
>>> font-lock-after-change-function ->
>>> font-lock-fontify-region ->
>>> font-lock-set-defaults
>>>
>>> Is the problem setting `font-lock-set-defaults' to nil? Is there
>>> anything else you can recommend?
>>
>> I think that I did test not setting `font-lock-set-defaults' to nil to
>> see if that made a difference, but the same problem was still there.
>>
>> I don't know very much myself, but in that section of code there is a
>> comment left by Stefan Monnier:
>>
>>   ;; FIXME: Use font-lock-add-keywords!
>
> Ha, my eyes went right by that comment.
>
>> So I would guess that the correct solution would be to add the citation
>> font-locking rules with `font-lock-add-keywords' and then remove them
>> again with `font-lock-remove-keywords' if the mode is ever disabled, and
>> if the highlighting needs an update after those changes, call
>> `font-lock-flush'.
>
> So maybe this is enough?
>
> (define-minor-mode gnus-message-citation-mode
>   "Minor mode providing more font-lock support for nested citations.
> When enabled, it automatically turns on `font-lock-mode'."
>   :lighter ""
>   (when (derived-mode-p 'message-mode)
>     (if gnus-message-citation-mode
> 	(font-lock-add-keywords nil gnus-message-citation-keywords)
>       (font-lock-remove-keywords nil gnus-message-citation-keywords))
>     (if font-lock-mode
> 	(font-lock-flush)
>       (gnus-message-citation-mode (font-lock-mode 1)))))

No, that doesn't do it. The thing is, even if you defuse this minor mode
entirely (I replaced the body with `(message "Whee!")'),
global-whitespace-mode has already been overridden by the time we come
to run this minor-mode function. It's already getting clobbered at some
earlier point.




This bug report was last modified 1 year and 157 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.