all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Eli Zaretskii <eliz@gnu.org>
Cc: acm@muc.de, emacs-devel@gnu.org
Subject: Re: Is there something like `on-display-functions'?
Date: Thu, 28 Jan 2010 14:37:11 -0500	[thread overview]
Message-ID: <jwv3a1qowqd.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <E1NaOBt-0007U9-Tj@fencepost.gnu.org> (Eli Zaretskii's message of "Thu, 28 Jan 2010 01:49:21 -0500")

>> Unless the two functions cooperate, there's no reason to presume that
>> the two functions will fontify the same amount of text, since the amount
>> is mostly arbitrarily chosen by the function themselves (and may need
>> rounding up because of line-granularity or other
>> foo-region-extend-function).
>> 
>> So if each function is written independently, it will (in general) not
>> fontify the same amount of text as the others, and it won't know how
>> much the others (if any) have fontified.  So none of the functions will
>> actually know on which portion of the text the `fontified' property
>> should be applied.
> The place where `fontified' property with a nil value is left after
> all fontification-functions are run is not very important.

On the contrary, it's very important.

> It's just the place where redisplay will stop next and call those
> functions again.

If function foo1 fontified to location 123 and foo2 to location 245 and
the property is set until 245 and the window ends at 200, then foo1 will
not be called again, and the display will show 123-200 without
foo1's fontification.

> If a function on that list needs to be sure it does
> not miss any text due to the position where a nil-valued `fontified'
> is placed, it should simply start from some earlier position, not from
> the one with which it is invoked.  Then it could search for the first
> position where it needs to do its job, and resume there.

Which "earlier position"?  How does the function know how far back it
would need to look?

> Note that the JIT Lock function that gets invoked via
> fontification-functions always starts from the beginning of the line
> to which the position it was invoked with belongs.  So it is already
> doing something similar, albeit for different reasons.

That used to be the case, but now this region-extension has been moved
to font-lock (where it belongs).

> OTOH, it would be a simple change to have the loop in
> handle_fontified_prop maintain the lowest buffer position of those
> where the `fontified' property was placed by any of the functions it
> invokes, and reset the value of that property to nil for that position
> after the loop finishes.  Would that resolve the difficulty?

We could try and solve the problem this way, yes.  Then again, it could
result in serious inefficiency if one of the functions works on 100B
chunks and the other on 1KB chunks, forcing the 1KB chunks to be
recomputed redundantly 10 times.

This said, I don't think it's a serious problem.  The way I look at it,
we should have used fontification-function rather than
fontification-functions, and that's it.

The "multiplexing" of several functions on this hook can be (and is)
performed by jit-lock, where it's easier to be more clever (although
currently jit-lock is not terribly clever either).


        Stefan





  reply	other threads:[~2010-01-28 19:37 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-27 13:57 Is there something like `on-display-functions'? Alan Mackenzie
2010-01-27 13:53 ` Lennart Borgman
2010-01-27 14:55   ` Alan Mackenzie
2010-01-27 15:11   ` Stefan Monnier
2010-01-27 15:37     ` Alan Mackenzie
2010-01-27 17:44       ` Eli Zaretskii
2010-01-27 19:24         ` Stefan Monnier
2010-01-27 20:08           ` Eli Zaretskii
2010-01-27 21:04             ` Stefan Monnier
2010-01-28  6:49               ` Eli Zaretskii
2010-01-28 19:37                 ` Stefan Monnier [this message]
2010-01-28 20:53                   ` Eli Zaretskii
2010-01-28 23:12                     ` Stefan Monnier
2010-01-29  9:09                       ` Eli Zaretskii
2010-01-29 18:08                         ` Stefan Monnier
2010-01-28  6:55               ` Eli Zaretskii
2010-01-28 10:38                 ` Alan Mackenzie
2010-01-28 12:54                   ` Eli Zaretskii
2010-01-28 14:47                     ` Alan Mackenzie
2010-01-28 19:18                       ` Eli Zaretskii
2010-01-29 13:09                         ` Alan Mackenzie
2010-01-28 19:37                   ` Stefan Monnier
2010-01-29 13:17                     ` Alan Mackenzie
2010-01-29 18:13                       ` Stefan Monnier
2010-01-29 19:17                         ` Alan Mackenzie
2010-01-30 21:02                           ` Stefan Monnier
2010-01-27 17:55       ` Eli Zaretskii
2010-01-28 10:27         ` Alan Mackenzie
2010-01-28 11:30       ` Doc patch for `fontification-functions': [was: Is there something like `on-display-functions'?] Alan Mackenzie
2010-01-28 15:34         ` Doc patch for `fontification-functions': Chong Yidong
2010-01-28 16:40           ` Alan Mackenzie
2010-01-28 18:38         ` Doc patch for `fontification-functions': [was: Is there something like `on-display-functions'?] Eli Zaretskii
2010-01-28 19:44         ` Doc patch for `fontification-functions': Stefan Monnier
2010-01-27 14:16 ` Is there something like `on-display-functions'? alin.s
2010-01-27 14:27 ` David Kastrup
2010-01-27 15:20   ` Alan Mackenzie
2010-01-27 16:31   ` Stephen J. Turnbull
2010-01-27 14:59 ` Davis Herring
2010-01-28  1:41 ` Daniel Colascione
2010-01-28 10:14   ` Alan Mackenzie
2010-01-28 19:39     ` Stefan Monnier

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

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

  git send-email \
    --in-reply-to=jwv3a1qowqd.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=acm@muc.de \
    --cc=eliz@gnu.org \
    --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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.