[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: On multi-line font lock

From: Stefan Monnier
Subject: Re: On multi-line font lock
Date: Fri, 15 Sep 2017 08:49:58 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

>   application/foobar; baz; copiousoutput; \
>   # not a comment \
>   # a comment

> I discovered an existing mailcap-mode here:
> which appears to take advantage of jit-lock-contextually.  I also
> managed to figure out syntax-propertize to a degree, with the help of
> some blog examples.

> However, I'm not fond of jit-lock's delay (which is
> configurable, but defaults are defaults are defaults), so I tried to get
> the non-jit-lock option to work.  The attached
> package somehow appears to be a working example of using
> font-lock-extend-region-functions.

font-lock is the wrong tool for this, since it's in charge of changing
the appearance of what's displayed and makes no effort to pay attention
to any part of the buffer that's not displayed.  But in your case you
care about "what is a comment and what isn't", which has effects beyond
appearance (e.g. it influences navigation commands).  So the only right
way to do this is with syntax-propertize-function (or equivalent).

You can still use font-lock-extend-region-functions in order to avoid
jit-lock's delay, of course.

> I'm puzzled because the function I've added to the hook always returns a
> truthy value AFAICT, and the documentation suggests the hook is run
> until all of its items return nil.

The code assumes that a function on that hook takes care of its own work.
So the non-nil value only causes *other* functions to be run.  If one of
those other functions returns non-nil, then we'll re-run yours.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]