From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: On multi-line font lock Date: Fri, 15 Sep 2017 08:49:58 -0400 Message-ID: References: <87o9qedrr9.fsf@holos> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1505479847 26025 195.159.176.226 (15 Sep 2017 12:50:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 15 Sep 2017 12:50:47 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Sep 15 14:50:41 2017 Return-path: Envelope-to: geh-help-gnu-emacs@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 1dsq4u-0006ZT-Lr for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Sep 2017 14:50:40 +0200 Original-Received: from localhost ([::1]:53250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsq51-0005Ua-UC for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Sep 2017 08:50:47 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35515) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dsq4X-0005U8-8P for help-gnu-emacs@gnu.org; Fri, 15 Sep 2017 08:50:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dsq4S-0008Tu-8K for help-gnu-emacs@gnu.org; Fri, 15 Sep 2017 08:50:17 -0400 Original-Received: from [195.159.176.226] (port=43295 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dsq4S-0008Sc-0z for help-gnu-emacs@gnu.org; Fri, 15 Sep 2017 08:50:12 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dsq4I-0005Wq-1v for help-gnu-emacs@gnu.org; Fri, 15 Sep 2017 14:50:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 36 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:vz1PkPfzYLJ5gGUfNkO0HFoo4H4= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:114287 Archived-At: > application/foobar; baz; copiousoutput; \ > # not a comment \ > # a comment > I discovered an existing mailcap-mode here: > http://user42.tuxfamily.org/mailcap-mode/index.html > which appears to take advantage of jit-lock-contextually. I also > managed to figure out syntax-propertize to a degree, with the help of > some blog examples. > However, I'm not fond of jit-lock's delay (which is > configurable, but defaults are defaults are defaults), so I tried to get > the non-jit-lock option to work. The attached > package somehow appears to be a working example of using > font-lock-extend-region-functions. font-lock is the wrong tool for this, since it's in charge of changing the appearance of what's displayed and makes no effort to pay attention to any part of the buffer that's not displayed. But in your case you care about "what is a comment and what isn't", which has effects beyond appearance (e.g. it influences navigation commands). So the only right way to do this is with syntax-propertize-function (or equivalent). You can still use font-lock-extend-region-functions in order to avoid jit-lock's delay, of course. > I'm puzzled because the function I've added to the hook always returns a > truthy value AFAICT, and the documentation suggests the hook is run > until all of its items return nil. The code assumes that a function on that hook takes care of its own work. So the non-nil value only causes *other* functions to be run. If one of those other functions returns non-nil, then we'll re-run yours. Stefan