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: Thu, 11 Jan 2024 11:57:36 +0000 Message-ID: <87o7dskrpr.fsf@ice9.digital> References: <8734v62rc2.fsf@ice9.digital> <87plyafahh.fsf@ericabrahamsen.net> <87r0iq1735.fsf@ice9.digital> <87le8xg3pg.fsf@ericabrahamsen.net> <87y1cwrg04.fsf@ice9.digital> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35943"; 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 Thu Jan 11 12:58:34 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 1rNthh-0009Bw-5W for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Jan 2024 12:58:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNthH-0001vD-Es; Thu, 11 Jan 2024 06:58:07 -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 1rNthG-0001rQ-Eg for bug-gnu-emacs@gnu.org; Thu, 11 Jan 2024 06:58:06 -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 1rNthF-00052p-2k for bug-gnu-emacs@gnu.org; Thu, 11 Jan 2024 06:58:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rNthC-0003Yd-2A for bug-gnu-emacs@gnu.org; Thu, 11 Jan 2024 06:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Morgan Willcock Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Jan 2024 11:58:02 +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.170497426913655 (code B ref 68352); Thu, 11 Jan 2024 11:58:02 +0000 Original-Received: (at 68352) by debbugs.gnu.org; 11 Jan 2024 11:57:49 +0000 Original-Received: from localhost ([127.0.0.1]:58850 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rNtgv-0003Y5-Dt for submit@debbugs.gnu.org; Thu, 11 Jan 2024 06:57:49 -0500 Original-Received: from relay7-d.mail.gandi.net ([2001:4b98:dc4:8::227]:35771) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rNtgt-0003Xo-3u for 68352@debbugs.gnu.org; Thu, 11 Jan 2024 06:57:44 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 5B2802000F; Thu, 11 Jan 2024 11:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ice9.digital; s=gm1; t=1704974257; 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=FCP276sF1gKN9FOa5BxTed/5M1VNxlbAafbdPKEAE2E=; b=iyYtsc63mEDOUUp8eQpVBbXn4qdAmB/N/TPGGbGZooH7dl8PNiWSryV+z/ebKSReAEoucp MH1O7O99OfZLBVczRs4lrxWgGECOWShIYwmXvBkG9qQ3YSpYGexKD0RB+v6BqWDrmYhlsW IWYAC1OKUognivWk+gv9gRrqmz+t0AO9upGmjUbS1nppaydgAQ1TtpyJ70Wimv7iw87pkA DGIVK1bmPsMxCzUw/M67xqhCdd8EUBJl5ImCiByfDWpllJb8dONPE0dAi2fxJtAtmtaWg5 HHcv9PwUbdpYy15RedJrGyJIqkvT+4PetOicUBJ8XRPPdwL7y/tgzUYL7m8Lvw== In-Reply-To: <87y1cwrg04.fsf@ice9.digital> (Morgan Willcock's message of "Wed, 10 Jan 2024 22:16:27 +0000") 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:277886 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Avoid-font-lock-reset-in-gnus-message-citation-mode.patch >From 9fa84932aa0ad7c37b20d68ca358ee779d225f09 Mon Sep 17 00:00:00 2001 From: Morgan Willcock 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 --=-=-=--