From: martin rudalics <rudalics@gmx.at>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: jit-lock doesn't honor font-lock-lines-before
Date: Thu, 01 Sep 2005 08:24:14 +0200 [thread overview]
Message-ID: <43169E8E.4020701@gmx.at> (raw)
In-Reply-To: <87r7cax1w0.fsf-monnier+emacs@gnu.org>
>>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 "\\<foo\\>" bound 'bound)
(save-excursion
(when (re-search-forward "\\<bar\\>" (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.
next prev parent reply other threads:[~2005-09-01 6:24 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 [this message]
2005-09-01 13:49 ` Stefan Monnier
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=43169E8E.4020701@gmx.at \
--to=rudalics@gmx.at \
--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).