unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
Subject: Re: On multi-line font lock
Date: Fri, 15 Sep 2017 08:49:58 -0400	[thread overview]
Message-ID: <jwvd16sdtku.fsf-monnier+gmane.emacs.help@gnu.org> (raw)
In-Reply-To: 87o9qedrr9.fsf@holos

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

> I discovered an existing mailcap-mode here:
> http://user42.tuxfamily.org/mailcap-mode/index.html
> 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.


        Stefan




  reply	other threads:[~2017-09-15 12:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-14  0:54 On multi-line font lock Mark Oteiza
2017-09-15 12:49 ` Stefan Monnier [this message]
2017-09-16 12:44   ` Mark Oteiza
2017-09-16 13:14     ` 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=jwvd16sdtku.fsf-monnier+gmane.emacs.help@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@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.
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).