all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Example matcher function for font-lock-keywords?
@ 2015-02-25 23:28 Alexis
  2015-02-25 23:34 ` Dmitry Gutov
  0 siblings, 1 reply; 3+ messages in thread
From: Alexis @ 2015-02-25 23:28 UTC (permalink / raw)
  To: help-gnu-emacs


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.

http://software-lab.de/doc/ref.html#transient 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,


Alexis.



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

* Re: Example matcher function for font-lock-keywords?
  2015-02-25 23:28 Example matcher function for font-lock-keywords? Alexis
@ 2015-02-25 23:34 ` Dmitry Gutov
  2015-02-26  1:48   ` Alexis
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Gutov @ 2015-02-25 23:34 UTC (permalink / raw)
  To: Alexis, help-gnu-emacs

On 02/26/2015 01:28 AM, Alexis wrote:

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

In all likelihood, that means you should implement a 
syntax-propertize-function, which would mark those occurrences of `#' 
with a different syntax class.

For usage examples, you can take a look at js-syntax-propertize and 
ruby-syntax-propertize-function.



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

* Re: Example matcher function for font-lock-keywords?
  2015-02-25 23:34 ` Dmitry Gutov
@ 2015-02-26  1:48   ` Alexis
  0 siblings, 0 replies; 3+ messages in thread
From: Alexis @ 2015-02-26  1:48 UTC (permalink / raw)
  To: help-gnu-emacs


On 2015-02-26T10:34:28+1100, Dmitry Gutov said:

 DG> In all likelihood, that means you should implement a DG> 
 syntax-propertize-function, which would mark those occurrences of 
 DG> `#' with a different syntax class.

 DG> For usage examples, you can take a look at 
 js-syntax-propertize DG> and ruby-syntax-propertize-function.

Ah, that looks promising .... Many thanks!


Alexis.



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

end of thread, other threads:[~2015-02-26  1:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-25 23:28 Example matcher function for font-lock-keywords? Alexis
2015-02-25 23:34 ` Dmitry Gutov
2015-02-26  1:48   ` Alexis

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.