From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#56637: 28.1.90; [FR] Allow a way around font-lock-mode being unconditionally disabled in " *hidden*" buffers Date: Tue, 19 Jul 2022 14:05:36 -0400 Message-ID: References: <874jzdhh5m.fsf@localhost> <83mtd5m54h.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24858"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 56637@debbugs.gnu.org, yantar92@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 19 20:16:43 2022 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 1oDrlx-0006EM-MW for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 19 Jul 2022 20:16:41 +0200 Original-Received: from localhost ([::1]:36942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDrlt-00028Q-7Q for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 19 Jul 2022 14:16:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDrbe-0007QX-Rn for bug-gnu-emacs@gnu.org; Tue, 19 Jul 2022 14:06:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57363) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDrbe-00076R-In for bug-gnu-emacs@gnu.org; Tue, 19 Jul 2022 14:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oDrbe-0005ze-Eh for bug-gnu-emacs@gnu.org; Tue, 19 Jul 2022 14:06:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 19 Jul 2022 18:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56637 X-GNU-PR-Package: emacs Original-Received: via spool by 56637-submit@debbugs.gnu.org id=B56637.165825394723012 (code B ref 56637); Tue, 19 Jul 2022 18:06:02 +0000 Original-Received: (at 56637) by debbugs.gnu.org; 19 Jul 2022 18:05:47 +0000 Original-Received: from localhost ([127.0.0.1]:55122 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oDrbP-0005z4-4p for submit@debbugs.gnu.org; Tue, 19 Jul 2022 14:05:47 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:15582) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oDrbM-0005yj-TU for 56637@debbugs.gnu.org; Tue, 19 Jul 2022 14:05:45 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 37FC98067B; Tue, 19 Jul 2022 14:05:39 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B79F98025B; Tue, 19 Jul 2022 14:05:37 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1658253937; bh=1lzQGIKkhBWe9witV/r9sjt37/J+PP+uDBz2S+Dtdcs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=KCU69hbpPMdduLUOsyR3clraMNRYfxdR2guMV2abSb1VfZvNmVDDbkm3w72Td7k4x ZdIYCT3ZeRoVyosvLuBLJLbSudIjicc6ZIdwCybVAn74qr4/F+jUSKCmPtsf2bKpbX BHmGUFqPGJsSKoH4Q9KeYoWAld/aNGSXHa/n1BJVRVK8oa+2vEE0cDkSfQ0oyZ29v+ h164OxhjoZ7gy/1zVuT5QhkcFaofHNNLcyymBQJjjwEIYlttFeJ9l90UwYTCqmtYyn UdBy1+7tBa5J/30qXaOXcIzVoADKsj9ypd8TQUwdtOBnGm9Ql9PJwnWS+p67LSa0x8 r1MQ7uq6yNOWQ== Original-Received: from pastel (unknown [45.72.196.165]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8A9931204B7; Tue, 19 Jul 2022 14:05:37 -0400 (EDT) In-Reply-To: (Stefan Monnier's message of "Tue, 19 Jul 2022 13:01:38 -0400") 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" Xref: news.gmane.io gmane.emacs.bugs:237460 Archived-At: > More seriously, I didn't mean to remove it willy-nilly, but that it's > a desirable goal and the question is how to get there. Of course, for that we need to know what effect this code has in practice, so I tried the patch below a the first few messages I got were: Enabling font-lock for mode minibuffer-inactive-mode in hidden buffer # Enabling font-lock for mode fundamental-mode in hidden buffer # Enabling font-lock for mode fundamental-mode in hidden buffer # Enabling font-lock for mode fundamental-mode in hidden buffer # Enabling font-lock for mode fundamental-mode in hidden buffer # Enabling font-lock for mode checkdoc-output-mode in hidden buffer # Enabling font-lock for mode minibuffer-mode in hidden buffer # Enabling font-lock for mode minibuffer-inactive-mode in hidden buffer # Enabling font-lock for mode minibuffer-inactive-mode in hidden buffer # Maybe it would be mostly "harmless" to enable font-lock in those buffers/modes, but even if it is, it would clearly be wasteful. Side note: the *checkdoc-temp* seems like an odd case. Its major mode is clearly designed for a "normal/visible" buffer (and IIUC it is indeed used in buffers that are displayed), so I'm not sure how *checkdoc-temp* ends up using that mode. Stefan diff --git a/lisp/font-core.el b/lisp/font-core.el index f92d1e38306..5678ab22da5 100644 --- a/lisp/font-core.el +++ b/lisp/font-core.el @@ -132,12 +132,15 @@ font-lock-mode ;; Don't turn on Font Lock mode if we don't have a display (we're running a ;; batch job) or if the buffer is invisible (the name starts with a space). (when (or noninteractive (eq (aref (buffer-name) 0) ?\s)) - (setq font-lock-mode nil)) + ;; (setq font-lock-mode nil) + (when font-lock-mode + (message "Enabling font-lock for mode %S in hidden buffer %S" + major-mode (current-buffer)))) (funcall font-lock-function font-lock-mode) ;; Arrange to unfontify this buffer if we change major mode later. (if font-lock-mode - (add-hook 'change-major-mode-hook 'font-lock-change-mode nil t) - (remove-hook 'change-major-mode-hook 'font-lock-change-mode t))) + (add-hook 'change-major-mode-hook #'font-lock-change-mode nil t) + (remove-hook 'change-major-mode-hook #'font-lock-change-mode t))) ;; Get rid of fontification for the old major mode. ;; We do this when changing major modes. @@ -270,7 +273,7 @@ global-font-lock-mode font-lock-mode turn-on-font-lock-if-desired ;; What was this :extra-args thingy for? --Stef ;; :extra-args (dummy) - :initialize 'custom-initialize-delay + :initialize #'custom-initialize-delay :init-value (not (or noninteractive emacs-basic-display)) :group 'font-lock :version "22.1")