From: Tassilo Horn <tsdh@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Migrating from font-lock-syntactic-keywords to syntax-propertize-function
Date: Tue, 12 May 2020 12:15:59 +0200 [thread overview]
Message-ID: <87sgg51msg.fsf@gnu.org> (raw)
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
next reply other threads:[~2020-05-12 10:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-12 10:15 Tassilo Horn [this message]
2020-05-12 13:44 ` Migrating from font-lock-syntactic-keywords to syntax-propertize-function Dmitry Gutov
2020-05-12 22:17 ` Tassilo Horn
2020-05-14 9:56 ` Tassilo Horn
2020-05-12 14:49 ` 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=87sgg51msg.fsf@gnu.org \
--to=tsdh@gnu.org \
--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).