unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: jit-lock doesn't honor font-lock-lines-before
Date: Thu, 01 Sep 2005 09:49:44 -0400	[thread overview]
Message-ID: <jwvwtm0zzhz.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <43169E8E.4020701@gmx.at> (martin rudalics's message of "Thu, 01 Sep 2005 08:24:14 +0200")

>>> 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û 2005 10:22:15 -0400	1.271
+++ font-lock.el	01 sep 2005 09:43:30 -0400	
@@ -293,7 +282,7 @@
 		 (integer :tag "size"))
   :group 'font-lock)
 
-(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)))))))
 
 (defun font-lock-fontify-block (&optional arg)

  reply	other threads:[~2005-09-01 13:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-28 13:08 jit-lock doesn't honor font-lock-lines-before martin rudalics
2005-08-29  8:39 ` Richard M. Stallman
2005-08-30  6:54   ` martin rudalics
2005-08-31  0:23     ` Richard M. Stallman
2005-09-01  6:22       ` martin rudalics
2005-09-01 14:11         ` Stefan Monnier
2005-09-02  5:24           ` martin rudalics
2005-09-02  6:04         ` Richard M. Stallman
2005-09-02 14:30           ` Stefan Monnier
2005-08-31 14:36     ` Richard M. Stallman
2005-08-29 14:13 ` Stefan Monnier
2005-08-30 12:11   ` martin rudalics
2005-08-31  2:47     ` Stefan Monnier
2005-09-01  6:24       ` martin rudalics
2005-09-01 13:49         ` Stefan Monnier [this message]
2005-09-02  6:05           ` Richard M. Stallman
2005-09-02 18:45             ` Stefan Monnier
2005-09-03  9:07               ` Richard M. Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvwtm0zzhz.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).