From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: jit-lock doesn't honor font-lock-lines-before Date: Thu, 01 Sep 2005 09:49:44 -0400 Message-ID: References: <4311B76B.1050406@gmx.at> <43144CF6.1070505@gmx.at> <87r7cax1w0.fsf-monnier+emacs@gnu.org> <43169E8E.4020701@gmx.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1125582856 20483 80.91.229.2 (1 Sep 2005 13:54:16 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 1 Sep 2005 13:54:16 +0000 (UTC) Cc: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 01 15:54:15 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EApTZ-0007zl-TR for ged-emacs-devel@m.gmane.org; Thu, 01 Sep 2005 15:51:34 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EApXo-00017s-He for ged-emacs-devel@m.gmane.org; Thu, 01 Sep 2005 09:55:56 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EApX7-0000tB-0E for emacs-devel@gnu.org; Thu, 01 Sep 2005 09:55:13 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EApWw-0000nO-5r for emacs-devel@gnu.org; Thu, 01 Sep 2005 09:55:03 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EApWv-0000ms-OJ for emacs-devel@gnu.org; Thu, 01 Sep 2005 09:55:01 -0400 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EApUo-0007pH-1m for emacs-devel@gnu.org; Thu, 01 Sep 2005 09:52:50 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id D23C72CF52C; Thu, 1 Sep 2005 09:49:52 -0400 (EDT) Original-Received: from asado.iro.umontreal.ca (asado.iro.umontreal.ca [132.204.24.84]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 406424AC00A; Thu, 1 Sep 2005 09:49:44 -0400 (EDT) Original-Received: by asado.iro.umontreal.ca (Postfix, from userid 20848) id 2BA925050; Thu, 1 Sep 2005 09:49:44 -0400 (EDT) Original-To: martin rudalics In-Reply-To: <43169E8E.4020701@gmx.at> (martin rudalics's message of "Thu, 01 Sep 2005 08:24:14 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-4.844, requis 5, autolearn=not spam, AWL 0.06, BAYES_00 -4.90) X-MailScanner-From: monnier@iro.umontreal.ca 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:42548 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? ....fumbling about... Hmm.... now I see what you mean. I simply assumed that the code for font-lock-lines-before had been added at the same place as the code for font-lock-multiline, so it would work just as well for jit-lock as for lazy-lock or anything else. As it currently stands, it indeed is broken. Sorry for being so stubborn. I suggest the patch below, which also sets the default value to 0: except for some special modes which rely on font-lock-lines-before (and which should thus set it explicitly to an appropriate value), setting it to something more than 0 will just waste CPU. > 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. I designed and implemented font-lock-multiline. It's a hack. It can't be fixed. If you want reliable and efficient multiline keywords, you have to specify them differently (read: change/extend the format of font-lock-keywords). Although you are right that you could get it to work more or less right for the special case of anchored keywords. Stefan --- font-lock.el 22 ao=FB 2005 10:22:15 -0400 1.271 +++ font-lock.el 01 sep 2005 09:43:30 -0400=09 @@ -293,7 +282,7 @@ (integer :tag "size")) :group 'font-lock) =20 -(defcustom font-lock-lines-before 1 +(defcustom font-lock-lines-before 0 "*Number of lines before the changed text to include in refontification." :type 'integer :group 'font-lock @@ -1049,6 +1038,8 @@ ;; Use the fontification syntax table, if any. (when font-lock-syntax-table (set-syntax-table font-lock-syntax-table)) + (goto-char beg) + (setq beg (line-beginning-position (- 1 font-lock-lines-before))) ;; check to see if we should expand the beg/end area for ;; proper multiline matches (when (and font-lock-multiline @@ -1105,8 +1096,7 @@ (save-match-data ;; Rescan between start of lines enclosing the region. (font-lock-fontify-region - (progn (goto-char beg) - (forward-line (- font-lock-lines-before)) (point)) + (progn (goto-char beg) (forward-line 0) (point)) (progn (goto-char end) (forward-line 1) (point))))))) =20 (defun font-lock-fontify-block (&optional arg)