From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Morgan Willcock Newsgroups: gmane.emacs.bugs Subject: bug#68352: 29.1; gnus-message-citation-mode removes values from font-lock-keywords Date: Wed, 10 Jan 2024 19:20:15 +0000 Message-ID: <87mstdgfm8.fsf@ice9.digital> References: <8734v62rc2.fsf@ice9.digital> <87plyafahh.fsf@ericabrahamsen.net> <87r0iq1735.fsf@ice9.digital> <87le8xg3pg.fsf@ericabrahamsen.net> <87wmshdxj1.fsf@ericabrahamsen.net> <875y01dnsq.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39557"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 68352@debbugs.gnu.org To: Eric Abrahamsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 10 20:21:41 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rNe8y-000A9X-JU for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Jan 2024 20:21:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNe8i-0006As-UE; Wed, 10 Jan 2024 14:21:25 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rNe8P-00065P-NU for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2024 14:21:09 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNe8N-00028S-0C for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2024 14:21:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rNe8L-0004Uo-Nt for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2024 14:21:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Morgan Willcock Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Jan 2024 19:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68352 X-GNU-PR-Package: emacs Original-Received: via spool by 68352-submit@debbugs.gnu.org id=B68352.170491442917227 (code B ref 68352); Wed, 10 Jan 2024 19:21:01 +0000 Original-Received: (at 68352) by debbugs.gnu.org; 10 Jan 2024 19:20:29 +0000 Original-Received: from localhost ([127.0.0.1]:43238 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rNe7o-0004Tn-Ow for submit@debbugs.gnu.org; Wed, 10 Jan 2024 14:20:29 -0500 Original-Received: from relay7-d.mail.gandi.net ([2001:4b98:dc4:8::227]:42167) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rNe7l-0004TU-PY for 68352@debbugs.gnu.org; Wed, 10 Jan 2024 14:20:27 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 948AA20004; Wed, 10 Jan 2024 19:20:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ice9.digital; s=gm1; t=1704914418; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MN12IgUpK4nN0fCRRAwI/YgHltx1jP7BZufijZ7jIKc=; b=WAnJj6o8vQGEcP9hcOrLA9kK0SWrk/zPbUfu6+0lIaaivrmywCtUKdnVMM1WvzpwXqBjef r9IHgH/7nmEx3Ir9ShGRJrcbfQK2r8bBnrCCAcK95bZ22TAi8UVrrVuz/zyFzV3kMFmg0S fPaLpdCA0q6jted9kvtevlc3Kp/9p5NFD98MdeuQJGQQKMgK7vWX+lxLJUYEMiYky6E+l9 ggW/mwAT54ifF+O+tFfZe1ijK9G5r8gqO2HpWlHVIMdGmOIPobg4Ayjbkp/QvzJq/0Tp0M X1d4u4kqWLRzSueIemssCCHMo3UpMHnWmezo/NB81QfLP12f3jBMSCbnTiiIKg== In-Reply-To: <875y01dnsq.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Wed, 10 Jan 2024 10:51:49 -0800") X-GND-Sasl: morgan@ice9.digital X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:277816 Archived-At: Eric Abrahamsen writes: > Eric Abrahamsen writes: > >> Eric Abrahamsen writes: >> >>> Morgan Willcock writes: >>> >>>> Eric Abrahamsen writes: >>>> >>>>> Morgan Willcock 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. > > Actually, it might just be that something about message-mode suppresses > whitespace-mode altogether. Even if I turn it on *after* starting a > reply, no font-locking of whitespace is done. I haven't had a chance to re-test anything yet (I'm fairly sure that removing the call to `font-lock-set-defaults' kept the whitespace font-lock rules in-place), but if you are seeing issues with whitespace-mode being turned on then it is probably because the value of `whitespace-enable-predicate' has not been modified. Because of the default predicate value, whitespace-mode does not apply to any buffer where the name begins with an asterisk (with the exception of the scratch buffer), and the message buffer is usually named something like "*unsent mail*". That is why the example to recreate the problem needed a change to the predicate value: (add-function :before-until whitespace-enable-predicate (lambda () (eq major-mode 'message-mode))) This might look a bit like I've hacked my way into creating the problem that I'm reporting, but this is actually what the docstring for the value instructs you to do to change the behaviour, and I don't think any of the default restrictions are there to avoid font-lock problems. -- Morgan Willcock