emacs-devel
[Top][All Lists]
Advanced

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

Re: Fontification using a syntax tree


From: Stefan Monnier
Subject: Re: Fontification using a syntax tree
Date: Sat, 18 Sep 2021 14:14:35 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> is, how should I go about doing this? From what I understand, font-lock
> works with syntax tables, but if I use a syntax table for font-lock, I'm

font-lock has various parts.  One part uses the syntax table to
highlight comments and strings.  This can be disabled by setting
`font-lock-keywords-only`.

Another part is the one that obeys `font-lock-keywords` and these
happily accept rules that consist of delegating the work to a function.

IOW you can just say

    (defconst foo-font-lock-keywords
      `((,#foo--fontify-upto)))

    (defun foo--fontify-upto (limit)
      ... Fontify between point and LIMIT ...
      ;; Return nil to tell font-lock that you're done.
      nil)

    (define-derived-mode ...
      ...
      (setq-local font-lock-defaults '(foo-font-lock-keywords t))
      ...)


-- Stefn




reply via email to

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