emacs-devel
[Top][All Lists]
Advanced

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

Re: multi-character syntactic entities in syntax tables


From: Dmitry Gutov
Subject: Re: multi-character syntactic entities in syntax tables
Date: Fri, 26 Apr 2013 22:53:42 +0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt)

Erik Charlebois <address@hidden> writes:

> One of the items in etc/TODO is:
>
> ** Beefed-up syntax-tables.
> *** recognize multi-character syntactic entities like `begin' and
> `end'.
>
> Lately I'm using languages where this would be quite useful and would
> be interested in adding support. Before I dive in, are there any
> strong opinions about how this should be implemented?
>
> The approach I was thinking of taking is defining a new syntax
> character class (let's say, *) which inherits from the previous
> character (recursively if the previous character is *). The important
> distinction is that they would not be treated as a new instance of
> that syntax class, so point movement by syntax class or paren matching
> would work (e.g. begin would be (****, and would only add 1 level of
> paren nesting).
>
> A mode would use a syntax-propertize-function to tag keywords with
> appropriate text properties. So something like Ruby:
>
> class Foo
> def Bar
> if condition
> ...
> end
> end
> end

ruby-mode code could definitely benefit from something like this.

> would have syntax classes like:
>
> (**** www
> (** www
> (* wwwwwwwww
> ...
> )**
> )**
> )**

I don't think using syntax-propertize-function is something the person
who wrote that TODO entry had in mind, but if we'll use it for that
purpose, at least in ruby-mode implementing something like a "generic
parenthesis" class should suffice (which would work similarly to generic
string and generic comment delimiters), since all non-curly blocks in
Ruby end the same way.

So, what's the rationale for your, more complex proposal? In what
context would treating e, g, i and n in "begin" as parenthesis openers
will be useful?



reply via email to

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