[Top][All Lists]

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

Example matcher function for font-lock-keywords?

From: Alexis
Subject: Example matcher function for font-lock-keywords?
Date: Thu, 26 Feb 2015 10:28:19 +1100

Hi all,

i'm working on a prog-mode for PicoLisp. The design of PicoLisp is such that strings are merely instances of what are called 'transient symbols'; one can do things like:

   (setq "My string" 10)

such that evaluating "My string" will yield the value 10. provides more details.

Consequently, the syntax table for PicoLisp should designate double-quotes as marking a symbol, not a string. This, however, means that syntactic highlighting of comments doesn't work properly - for example, when the comment character '#' appears inside a transient symbol, it /shouldn't/ be treated as a comment character (and the remainder of the line following it shouldn't be treated as a comment).

Initially i tried to handle this by using a regex in the mode's font-lock-keywords list, but that quickly became unwieldy. So instead, i'd like to use a matcher function in that list.

The documentation for `font-lock-keywords` says:

"MATCHER can be either the regexp to search for, or the function name to call to make the search (called with one argument, the limit of the search; it should return non-nil, move point, and set `match-data' appropriately if it succeeds; like `re-search-forward' would)."

Having played around with trying to create such a function, using both `re-search-forward` and `string-match`, i can't seem to get any highlighting at all, let alone correct highlighting.

Could someone please point me to an example 'in-production' matcher function, e.g. in the Emacs ELisp code base?

Thanks in advance,


reply via email to

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