unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Alan Mackenzie <acm@muc.de>
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: Is there something like `on-display-functions'?
Date: Wed, 27 Jan 2010 19:44:22 +0200	[thread overview]
Message-ID: <83k4v34f49.fsf@gnu.org> (raw)
In-Reply-To: <20100127153733.GD3432@muc.de>

> Date: Wed, 27 Jan 2010 15:37:33 +0000
> From: Alan Mackenzie <acm@muc.de>
> Cc: Lennart Borgman <lennart.borgman@gmail.com>, emacs-devel@gnu.org
> 
> > I'd recommend you use jit-lock instead (via jit-lock-register), tho,
> > because fontification-functions (despite its name) really only works
> > well with a single function (at least I don't know how to make it work
> > well with more than one, based on how it's currently defined).
> 
> Is that because it's got to set 'fontified' properties?

No, I don't think so.  The handler of the `fontified' property checks
for the property's value being nil only once, and then runs all the
functions in fontification-functions in a loop.  The relevant code is
below.

Stefan, could you perhaps show a reproducible test case for this?

 ----------------------------------------------------------------------
  /* Get the value of the `fontified' property at IT's current buffer
     position.  (The `fontified' property doesn't have a special
     meaning in strings.)  If the value is nil, call functions from
     Qfontification_functions.  */
  if (!STRINGP (it->string)
      && it->s == NULL
      && !NILP (Vfontification_functions)
      && !NILP (Vrun_hooks)
      && (pos = make_number (IT_CHARPOS (*it)),
	  prop = Fget_char_property (pos, Qfontified, Qnil),
	  /* Ignore the special cased nil value always present at EOB since
	     no amount of fontifying will be able to change it.  */
	  NILP (prop) && IT_CHARPOS (*it) < Z))
    {
      int count = SPECPDL_INDEX ();
      Lisp_Object val;

      val = Vfontification_functions;
      specbind (Qfontification_functions, Qnil);

      if (!CONSP (val) || EQ (XCAR (val), Qlambda))
	safe_call1 (val, pos);
      else
	{
	  Lisp_Object globals, fn;
	  struct gcpro gcpro1, gcpro2;

	  globals = Qnil;
	  GCPRO2 (val, globals);

	  for (; CONSP (val); val = XCDR (val))
	    {
	      fn = XCAR (val);

	      if (EQ (fn, Qt))
		{
		  /* A value of t indicates this hook has a local
		     binding; it means to run the global binding too.
		     In a global value, t should not occur.  If it
		     does, we must ignore it to avoid an endless
		     loop.  */
		  for (globals = Fdefault_value (Qfontification_functions);
		       CONSP (globals);
		       globals = XCDR (globals))
		    {
		      fn = XCAR (globals);
		      if (!EQ (fn, Qt))
			safe_call1 (fn, pos);
		    }
		}
	      else
		safe_call1 (fn, pos);
	    }

	  UNGCPRO;
	}

      unbind_to (count, Qnil);




  reply	other threads:[~2010-01-27 17:44 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 [this message]
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
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

  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=83k4v34f49.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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).