unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Migrating from font-lock-syntactic-keywords to syntax-propertize-function
@ 2020-05-12 10:15 Tassilo Horn
  2020-05-12 13:44 ` Dmitry Gutov
  2020-05-12 14:49 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Tassilo Horn @ 2020-05-12 10:15 UTC (permalink / raw)
  To: help-gnu-emacs

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   



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-05-14  9:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-12 10:15 Migrating from font-lock-syntactic-keywords to syntax-propertize-function Tassilo Horn
2020-05-12 13:44 ` Dmitry Gutov
2020-05-12 22:17   ` Tassilo Horn
2020-05-14  9:56     ` Tassilo Horn
2020-05-12 14:49 ` Stefan Monnier

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).