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: Andreas Röhler
Subject: Re: emacs: are multi-char parentheses possible?
Date: Tue, 10 Jun 2014 07:13:51 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Icedove/24.5.0

On 09.06.2014 17:38, Stefan Monnier wrote:
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



With thingatpt you may specify arbitrary strings as delimiters.
Maybe that's an option in context also.

Andreas




reply via email to

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