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 15:21:22 -0400 Message-ID: References: <874jzdhh5m.fsf@localhost> <83mtd5m54h.fsf@gnu.org> <83ilntlydv.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="6783"; 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 21:23:03 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 1oDsoA-0001XR-26 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 19 Jul 2022 21:23:02 +0200 Original-Received: from localhost ([::1]:58346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDso8-0000pq-FZ for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 19 Jul 2022 15:23:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDsnC-0008T8-Nt for bug-gnu-emacs@gnu.org; Tue, 19 Jul 2022 15:22:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57417) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oDsnC-0005lw-FB for bug-gnu-emacs@gnu.org; Tue, 19 Jul 2022 15:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oDsnC-0007uj-An for bug-gnu-emacs@gnu.org; Tue, 19 Jul 2022 15:22: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 19:22: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.165825849530388 (code B ref 56637); Tue, 19 Jul 2022 19:22:02 +0000 Original-Received: (at 56637) by debbugs.gnu.org; 19 Jul 2022 19:21:35 +0000 Original-Received: from localhost ([127.0.0.1]:55176 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oDsmk-0007u4-Jw for submit@debbugs.gnu.org; Tue, 19 Jul 2022 15:21:34 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:3106) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oDsmi-0007to-1C for 56637@debbugs.gnu.org; Tue, 19 Jul 2022 15:21:33 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4F05A10012E; Tue, 19 Jul 2022 15:21:26 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 2972C100102; Tue, 19 Jul 2022 15:21:24 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1658258484; bh=G1pHpHQguQ17hEHsN8aBnkB0akOA2PkUxw1zwc0s5XY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ULsHYix4iuE6WPa2o370NsFSVW4d2Aknc+kkzm8SDrIg+MPkRqCDGM8tAfnq7nwWI xryutmGN22sMB3zCbO2/bsvyYKcvHto4WyF3iybC9povR3JqvqVMEIlPOmsJ33wL71 Az/sHiryuw7lqKK3gzPo+buqp1P/jUapQEgsWqXrZswSPDnGV5IokgvhhdnRp+KH6u fhDiarGUz+7NremjjgFPneoql6pc/Ie3NZ2hfpolDTev+DecIqjyOo5axYnJX4bhI2 KMOIX9GmdlVlVTVvffqdbGnieD7NdYDbQ3gXFpcnAk2I4k2U03I3kxa/UrDyxycI6a FNP1Xgs1tjtOg== Original-Received: from pastel (unknown [45.72.196.165]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id DF30512013E; Tue, 19 Jul 2022 15:21:23 -0400 (EDT) In-Reply-To: <83ilntlydv.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 19 Jul 2022 22:02:04 +0300") 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:237464 Archived-At: >> >> FWIW, I do think it would be good to remove the rule that font-lock is >> >> never enabled in temp buffers. >> > I don't. >> I think we agree :-) >> 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. > Why is that a desirable goal? Because testing `noninteractive` and the presence of a leading space are just heuristics and they aren't quite right. IOW it's a handy hack but it's just a hack. > It slows down stuff that is never displayed. That's why I say that we shouldn't do it "willy-nilly". > And if that buffer has very long lines, it slows Emacs down considerably. I think currently it should basically never be the case, because the actual fontification (the part which pays attention to lines) only happens via jit-lock, which should never trigger if those buffers aren't displayed. Also, most of those buffers have no font-lock rules installed so (font-lock-specified-p mode) should return nil and `font-lock-default-function` won't call `font-lock-mode-internal`. But yes, if we do it naively, we'll surely bump into corner cases where there happens to be font-lock rules setup and where jit-lock is disabled for some reason, or something else ends up causing some of the font-lock machinery to be run. Or maybe just running font-lock's setup code itself ends up too costly for some reason. >> We could start by adding a new variable >> `font-lock-allow-in-temporary-buffer`, which packages could set >> buffer-locally in those rare temp buffers where they do want to enable >> font-lock, as in the untested patch below. > This is a slippery slope. Next some other corner case will want to > run buffer-modification hooks in a temporary buffer, so we invent > another variable, and so on and so forth. Hmm... we do run buffer-modification hooks in temp buffers. > I'd rather introduce a macro like with-temp-buffer, but one that can > accept a buffer name, and ask such applications to please name their > temporary buffers something that doesn't begin with a space. The purpose of the leading space, AFAIK is to avoid displaying the buffer in `read-buffer`. Forcing those buffers to appear in `read-buffer` just because we need to run font-lock in there sounds wrong. If you don't like `font-lock-allow-in-temporary-buffer`, we could have a new function `font-lock-enable-unconditionally` which does the same as `font-lock-mode` but skips the (or noninteractive (eq (aref (buffer-name) 0) ?\s)) test. Stefan