emacs-devel
[Top][All Lists]
Advanced

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

Re: font lock with functions


From: Stefan Monnier
Subject: Re: font lock with functions
Date: Tue, 31 Mar 2020 09:20:37 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> - It is very easy during testing to completely hang your Emacs session
>   if one of the font-lock functions hangs. One usually needs to kill
>   Emacs in this case.

`jit-lock-debug-mode` might be helpful there.
If it's not good enough for your situation, please `M-x report-emacs-bug`.

>   We should try to get this into ELPA and advertise it in the manual:
>
>    https://github.com/Lindydancer/font-lock-studio

Agreed.

> On a more general note: When you use functions for font-locking, I often
> find myself in the position that I'm more or less writing a parser, and
> I could readily tell font-lock how to fontify several parts of the
> buffer with different faces. However, AFAICS, this is not possible with
> current font-lock?

You can't use the `font-lock-keywords` special syntax for that, but you
can still do it (by hand).  E.g.

    (defvar foo-font-lock-keywords
        `(("someregexp" (1 'foo-face) (2 'bar-face))
          (my-parsing-function)))

    (defun my-parsing-function (limit)
      ...
      (while ...
        (put-text-property x y 'face 'foobar-face)
        ...)
      ;; Return nil if you don't want font-lock to call you again right away
      ;; to "look for the next match".
      nil)


-- Stefan




reply via email to

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