emacs-devel
[Top][All Lists]
Advanced

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

Re: emacs: are multi-char parentheses possible?


From: Stefan Monnier
Subject: Re: emacs: are multi-char parentheses possible?
Date: Mon, 09 Jun 2014 11:38:44 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

> Do you know if it is possible for Emacs to handle a pair of multi-char
> parentheses?

Yes, I do.  I also know the answer is not just a plain boolean.

> Take << and >> for example,
>
> (setq-local syntax-propertize-function (syntax-propertize-rules
>                                           ("\\(<\\)<" (1 "(>"))
>                                           (">\\(>\\)" (1 ")<"))))
>
> show-paren-mode can highlight "<<" and ">>" but up-list aren't aware of
> them.

up-list should handle this just as well as show-paren and
for/backward-sexp (and does, in my tests).

Maybe you tried a "forward up-list" where the closing ">>" hadn't yet been
syntax-propertized?

This technique has some downsides, but in the case of << ... >> it might
work well enough.

For things like "begin...end" it's more annoying (e.g. backward word
will stop right between the "b" and the "egin" and forward-word will
stop right between "en" and "d").  For those, SMIE might be a better
option (which uses hooks in show-paren and forward-sexp to try and make
them do The Right Thing, tho the up-list case is only 90% working).


        Stefan



reply via email to

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