From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: hi-lock mode and special buffers Date: Thu, 24 Nov 2005 13:03:13 -0500 Message-ID: <87sltlylcu.fsf@stupidchicken.com> References: <87ek563ytf.fsf@pacem.orebokech.com> <87ek56c8as.fsf@stupidchicken.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1132855931 14590 80.91.229.2 (24 Nov 2005 18:12:11 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 24 Nov 2005 18:12:11 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 24 19:12:10 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EfLYx-0004kt-Ji for ged-emacs-devel@m.gmane.org; Thu, 24 Nov 2005 19:11:15 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EfLYw-0008I0-Kj for ged-emacs-devel@m.gmane.org; Thu, 24 Nov 2005 13:11:14 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EfLRA-0004lY-JK for emacs-devel@gnu.org; Thu, 24 Nov 2005 13:03:12 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EfLR9-0004lA-S3 for emacs-devel@gnu.org; Thu, 24 Nov 2005 13:03:12 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EfLR9-0004l5-Ng for emacs-devel@gnu.org; Thu, 24 Nov 2005 13:03:11 -0500 Original-Received: from [18.95.5.42] (helo=localhost.localdomain) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EfLR9-0006kR-2D for emacs-devel@gnu.org; Thu, 24 Nov 2005 13:03:11 -0500 Original-Received: by localhost.localdomain (Postfix, from userid 1000) id 7E1D31E41FE; Thu, 24 Nov 2005 13:03:13 -0500 (EST) Original-To: Romain Francoise In-Reply-To: <87ek56c8as.fsf@stupidchicken.com> (Chong Yidong's message of "Thu, 24 Nov 2005 11:36:11 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:46529 Archived-At: After studying hi-lock.el more closely, I think there is more than one problem at work here. First of all, `M-x highlight-regexp' turns on hi-lock-mode in all buffers. This is unnecessary. I suggest the following fix: 1. Using define-minor-mode, define a buffer-local minor-mode `hi-lock-buffer-mode' that does the same stuff as the current `hi-lock-mode'. 2. Using define-global-minor-mode, define `hi-lock-mode' as a global mode that turns on `hi-lock-buffer-mode'. This will avoid having to set font-lock-defaults for all buffers, only the local buffer. The global-minor-mode will turn on the local mode, which can set font-lock-defaults just for that buffer. So the Gnus group buffer won't lose when you use highlight-regexp elsewhere in Emacs. (This was why my change made the bug surface -- it made hi-lock-mode really take effect everywhere in Emacs.) This does not address the incompatibility between the Gnus group buffer and hi-lock-mode. The reason for *that* is that Gnus tweaks the 'face property directly, instead of using font lock. On the other hand, hi-lock works by adding the regexp that you want to highlight to font-lock-keywords, and calling font-lock-fontify-buffer. This wipes the existing face properties. (Incidentally, you don't need hi-lock for this; go to the Gnus group and run M-x font-lock-fontify-buffer). So we need another fix for this problem. I suggest making hi-lock highlight faces on the first pass by altering the face properties in the buffer directly. At the same time, it adds the desired regexp to font-lock-keywords, but does *not* call font-lock-fontify-buffer. When the buffer is subsequently changed, the changes will be fontified by the font-lock engine. Sound like a plan?