From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: RE: compilation-mode, face, font-lock-face Date: Thu, 2 Feb 2017 09:33:20 -0800 (PST) Message-ID: <9900a3e7-0c34-47ed-92df-e822e7089859@default> References: <86bmuk27bv.fsf@stephe-leake.org> <87tw8ckdxo.fsf@drachen> <867f581qwq.fsf@stephe-leake.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1486056817 24537 195.159.176.226 (2 Feb 2017 17:33:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 2 Feb 2017 17:33:37 +0000 (UTC) To: Stephen Leake , emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 02 18:33:34 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZLGH-0006Dk-O9 for ged-emacs-devel@m.gmane.org; Thu, 02 Feb 2017 18:33:33 +0100 Original-Received: from localhost ([::1]:58143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZLGN-00015V-5Q for ged-emacs-devel@m.gmane.org; Thu, 02 Feb 2017 12:33:39 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZLGD-00013w-G0 for emacs-devel@gnu.org; Thu, 02 Feb 2017 12:33:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZLGA-0000yt-EW for emacs-devel@gnu.org; Thu, 02 Feb 2017 12:33:29 -0500 Original-Received: from userp1040.oracle.com ([156.151.31.81]:32973) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cZLGA-0000yP-4j for emacs-devel@gnu.org; Thu, 02 Feb 2017 12:33:26 -0500 Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v12HXNUX014843 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Feb 2017 17:33:23 GMT Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v12HXMJB005549 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Feb 2017 17:33:23 GMT Original-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v12HXL8r011315; Thu, 2 Feb 2017 17:33:22 GMT In-Reply-To: <867f581qwq.fsf@stephe-leake.org> X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 12.0.6753.5000 (x86)] X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 156.151.31.81 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:211880 Archived-At: > font-lock-mode returns nil, so somehow it is being disabled. > Ah; font-lock-mode contains this: >=20 > (when (or noninteractive (eq (aref (buffer-name) 0) ?\s)) > (setq font-lock-mode nil)) >=20 > my buffer name begins with a space; it is supposed to be normally > invisible to users, only exposed when it has interesting stuff. Removing > that space enables font-lock. That part of the `font-lock-mode' definition seems misguided, to me. In general, a mode should not, itself, decide when it is to be turned on or off. (Yes, there can be exceptions, but they should apply only when it is impossible or it never makes sense for the mode to be enabled.) This is the comment before that code: ;; 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). OK, I can understand that if there is no display then there _cannot_ be any font-locking, so the `noninteractive' test makes sense, I guess. But the part about the buffer name seems very wrong. Not to mention that the comment does not speak the truth: a buffer is _not_ necessarily invisible just because its name starts with a space. Users are perfectly capable of displaying a buffer whose name begins with a space. And there is no hard reason why such a buffer should not be entitled to font-locking, if that's what someone wants. To me, this seems like a gratuitous bug. A guess is that this was added as a "convenience", so code that uses font-lock-mode need not, itself, turn the mode off for a buffer with a space-prefixed name. That's a reasonable use case, but hard-coding that behavior in the mode itself is not the right approach, I think. You should be able to turn `font-lock-mode' on for a buffer without regard to its name. If we feel the need for a mode that reflects the common use case of, by default, inhibiting `font-lock-mode' based on buffer name, then I suggest we add a variable, `font-lock-inhibiting-buffer-name-regexp', or `font-lock-ignore-buffer-regexp', or some such, whose value is a regexp which, if matched by a buffer name, inhibits the mode. (It could also be a list of such regexps.) The code could then be something like this: (defvar font-lock-ignore-buffer-regexp "\\` " "Regexp match of this against buffer name turns off `font-lock-mode'.") ;; Turn off the mode if we don't have a display (we're running a ;; batch job) or if the buffer name requires it. (when (or noninteractive (string-match font-lock-ignore-buffer-regexp (buffer-name))) (setq font-lock-mode nil)) (The variable could also be a defcustom.) Exactly that regexp is used for `desktop-buffers-not-to-save', BTW: (defcustom desktop-buffers-not-to-save "\\` " "Regexp identifying buffers that are to be excluded from saving." :type '(choice (const :tag "None" nil) =09=09 regexp) :version "24.4" ; skip invisible temporary buffers :group 'desktop) (Unfortunately, the doc string here is wrong/incomplete: the value is not necessarily a regexp.) Similarly, option `ido-ignore-buffers': (defcustom ido-ignore-buffers '("\\` ") "List of regexps or functions matching buffer names to ignore...