From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: jit-lock doesn't honor font-lock-lines-before Date: Thu, 01 Sep 2005 08:24:14 +0200 Message-ID: <43169E8E.4020701@gmx.at> References: <4311B76B.1050406@gmx.at> <43144CF6.1070505@gmx.at> <87r7cax1w0.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1125559172 4296 80.91.229.2 (1 Sep 2005 07:19:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 1 Sep 2005 07:19:32 +0000 (UTC) Cc: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 01 09:19:31 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EAjJI-0005jr-HJ for ged-emacs-devel@m.gmane.org; Thu, 01 Sep 2005 09:16:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EAjNV-0007lZ-Az for ged-emacs-devel@m.gmane.org; Thu, 01 Sep 2005 03:20:53 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EAixv-0008Kn-Rh for emacs-devel@gnu.org; Thu, 01 Sep 2005 02:54:29 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EAixp-0008K8-2c for emacs-devel@gnu.org; Thu, 01 Sep 2005 02:54:21 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EAixj-0007wm-FT for emacs-devel@gnu.org; Thu, 01 Sep 2005 02:54:16 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.34) id 1EAiWm-0000S7-OF for emacs-devel@gnu.org; Thu, 01 Sep 2005 02:26:25 -0400 Original-Received: (qmail invoked by alias); 01 Sep 2005 06:23:30 -0000 Original-Received: from N818P015.adsl.highway.telekom.at (EHLO [62.47.46.47]) [62.47.46.47] by mail.gmx.net (mp035) with SMTP; 01 Sep 2005 08:23:30 +0200 X-Authenticated: #14592706 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en Original-To: Stefan Monnier In-Reply-To: <87r7cax1w0.fsf-monnier+emacs@gnu.org> X-Y-GMX-Trusted: 0 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:42544 Archived-At: >>Suppose not: Wouldn't that mean `font-lock-lines-before' is useless? > > > Not at all. Then you mean that `font-lock-lines-before' is useless with jit-lock? > ... font-lock-lines-before has not been introduced to force > refontification of the previous lines but because the N previous lines are > needed as context in order to properly refontify the current line. > Now the code does in fact refontify the previous lines, but it is > a side-effect rather than one of the original goals. > > When the "N previous lines" have not been fontified yet because they are before `window-start' you do have to fontify them anyway. Otherwise any - syntactical, for example - context infomation needed to fontify the current line correctly might be invalid. >>It's not very difficult to contrive test cases for this. By default >>`font-lock-multiline' is nil. `font-lock-fontify-anchored-keywords' >>won't alter it - the appropriate lines have been commented out. Write >>an arbitrary multiline pattern. Now font-lock won't give it the >>`font-lock-multiline' text property and jit-lock not necessarily reset >>its `fontified' text property after a change. `font-lock-after-change', >>on the other hand, may refontify it provided `font-lock-lines-before' is >>large enough. > > > Please show me a test case. > > Try (defun foobar (bound) (while (re-search-forward "\\" bound 'bound) (save-excursion (when (re-search-forward "\\" (line-end-position 2) 'lep) (font-lock-prepend-text-property (match-beginning 0) (match-end 0) 'face 'font-lock-warning-face))))) (defun foobar-add () (interactive) (font-lock-add-keywords nil '(foobar . nil) t)) In some buffer do `foobar-add', write "foo" on one line and "bar" on the next. Plain font-lock will handle it, jit-lock won't. >>However, I believe that `font-lock-lines-before' is a brute force >>approach to handle such cases and could remarkably slow down editing if >>it were honored by jit-lock mode. Multiline patterns are too delicate >>and should be treated in a completely different way. > > > Indeed, but nobody has put the work needed to handle them properly. > font-lock-multiline is one hack, font-lock-lines-before is another, > font-lock-fontification-face-function is yet another. I don't know about font-lock-fontification-face-function. `font-lock-multiline' is not a hack, at least not a priori. It simply has not been developed yet. `font-lock-lines-before' is a brute hack. However, until `font-lock-multiline' is implemented correctly, it might be better than nothing.