help-gnu-emacs
[Top][All Lists]
Advanced

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

Migrating from font-lock-syntactic-keywords to syntax-propertize-functio


From: Tassilo Horn
Subject: Migrating from font-lock-syntactic-keywords to syntax-propertize-function
Date: Tue, 12 May 2020 12:15:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Hi all,

I want to convert some old fontification code from using the now
obsolete `font-lock-syntactic-keywords' variable to using a custom
`syntax-propertize-function'.

Looking at examples inside Emacs itself, it seems the way to go is using
something like

  (defun my-make-syntax-propertize-function ()
    (syntax-propertize-rules
      ;; My rules here.
      ))

and then

  (setq-local syntax-propertize-function
              (my-make-syntax-propertize-function))

when setting up fontification.

Now I have two questions:

1. With `font-lock-syntactic-keywords', a MATCH-HIGHLIGHT could have the
   form (SUBEXP SYNTAX OVERRIDE LAXMATCH) but with
   `syntax-propertize-rules' only (NUMBER SYNTAX) is allowed where
   SUBEXP and NUMBER have the same meaning.  So how does one convert
   entries which use OVERRIDE and/or LAXMATCH to the new mechanism?  (I
   don't use LAXMATCH, so that's not too important.)

2. Some of my syntax rules are not static, so I cannot provide a fixed
   set of rules to `syntax-propertize-rules'.  Is there anything better
   than using `eval' like

     (defun my-make-syntax-propertize-function ()
       (eval
        `(syntax-propertize-rules
          ,@(mapcar
             #'my-convert-legacy-syntactic-keywords
             (my-compute-syntactic-keywords)))))

   or should I prefer writing a manual `syntax-propertize-function'?

Bye,
Tassilo   



reply via email to

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