From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Leo Liu <sdl.web@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: emacs: are multi-char parentheses possible?
Date: Mon, 09 Jun 2014 11:38:44 -0400 [thread overview]
Message-ID: <jwvbnu2w15i.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <m3ppiilhna.fsf@gmail.com> (Leo Liu's message of "Mon, 09 Jun 2014 14:30:01 +0800")
> 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
next parent reply other threads:[~2014-06-09 15:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <m3ppiilhna.fsf@gmail.com>
2014-06-09 15:38 ` Stefan Monnier [this message]
2014-06-10 0:14 ` emacs: are multi-char parentheses possible? Leo Liu
2014-06-10 2:21 ` Stefan Monnier
2014-06-10 9:22 ` Leo Liu
2014-06-10 20:20 ` Stefan Monnier
2014-06-11 7:40 ` Andreas Röhler
2014-06-10 5:13 ` Andreas Röhler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvbnu2w15i.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@gnu.org \
--cc=sdl.web@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).