unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 56637@debbugs.gnu.org, yantar92@gmail.com
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	[thread overview]
Message-ID: <jwvr12hkmu4.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwvy1wpkpt7.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Tue, 19 Jul 2022 13:01:38 -0400")

> 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 #<buffer  *Minibuf-0*>
    Enabling font-lock for mode fundamental-mode in hidden buffer #<buffer  *load*>
    Enabling font-lock for mode fundamental-mode in hidden buffer #<buffer  *Echo Area 0*>
    Enabling font-lock for mode fundamental-mode in hidden buffer #<buffer  *Echo Area 1*>
    Enabling font-lock for mode fundamental-mode in hidden buffer #<buffer  *load*-628722>
    Enabling font-lock for mode checkdoc-output-mode in hidden buffer #<buffer  *checkdoc-temp*>
    Enabling font-lock for mode minibuffer-mode in hidden buffer #<buffer  *Minibuf-1*>
    Enabling font-lock for mode minibuffer-inactive-mode in hidden buffer #<buffer  *Minibuf-0*>
    Enabling font-lock for mode minibuffer-inactive-mode in hidden buffer #<buffer  *Minibuf-1*>

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")






  reply	other threads:[~2022-07-19 18:05 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19  4:15 bug#56637: 28.1.90; [FR] Allow a way around font-lock-mode being unconditionally disabled in " *hidden*" buffers Ihor Radchenko
2022-07-19 12:55 ` Eli Zaretskii
2022-07-20  4:13   ` Ihor Radchenko
2022-07-20 11:32     ` Eli Zaretskii
2022-07-21 12:09       ` Ihor Radchenko
2022-07-21 12:26         ` Eli Zaretskii
2022-07-21 12:44           ` Ihor Radchenko
2022-07-21 12:49             ` Eli Zaretskii
2022-07-21 13:18               ` Ihor Radchenko
2022-07-21 15:13         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-24  6:40           ` Ihor Radchenko
2022-07-19 16:13 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-19 16:36   ` Eli Zaretskii
2022-07-19 17:01     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-19 18:05       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-07-19 19:02       ` Eli Zaretskii
2022-07-19 19:21         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-19 19:32           ` Eli Zaretskii
2022-07-19 21:12             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-20 11:12               ` Eli Zaretskii
2022-07-20 15:15                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-20 16:09                   ` Eli Zaretskii
2022-07-20 19:15                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-20  4:15   ` Ihor Radchenko
2022-07-20 14:58     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-21 12:11       ` Ihor Radchenko
2022-07-21 18:39         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-24  6:47           ` Ihor Radchenko
2022-07-24 14:25             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-25  9:23               ` Ihor Radchenko
2022-07-25 15:56                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-07-26  5:21                   ` Ihor Radchenko
2022-07-23  7:53       ` Lars Ingebrigtsen
2022-07-23  8:55         ` Eli Zaretskii
2022-07-23 13:46         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvr12hkmu4.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=56637@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=yantar92@gmail.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).