From: Alan Mackenzie <acm@muc.de>
To: "Herman, Géza" <geza.herman@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Parenthesis matching should consider the kind of parenthesis during pair-search
Date: Mon, 12 Feb 2024 14:07:27 +0000 [thread overview]
Message-ID: <ZcomHxJHapm5-_gm@ACM> (raw)
In-Reply-To: <87mss56cgs.fsf@gmail.com>
Hello, Géza
On Mon, Feb 12, 2024 at 14:10:06 +0100, Herman, Géza wrote:
> Alan Mackenzie <acm@muc.de> writes:
> >> What do you think, shouldn't Emacs consider the kind of parenthesis
> >> when during searching for a pair? (in other words, it should ignore
> >> all other kinds of parentheses when it searches for a pair)
> > No, I don't think that. ;-) A lot of the time (?most of the time),
> > we want Emacs to point out paren mismatch errors, and that
> > alternative way of scanning parens would prevent this.
> The only gain with the current way is that Emacs will point out
> the mismatch (considering my Makefile example), if the cursor is
> on the opening '('. With my suggested method, it's not the
> mismatch which would be shown, but the pair of '(' would (which is
> actually a correct behavior in this case, the pair of '(' is
> indeed the ')' ).
OK, I don't agree with some of the things you're saying, but why don't
you implement your idea so that we can try it out?
> All the other interactions would be the same.
That's a bold thing to say, indeed!
> If you put the cursor on the '}', Emacs would still show that it
> is a paren without a pair, just like now (but instead of saying
> that its "pair" is the '(', it wouldn't show anything, because '}'
> doesn't have a pair.
What if earlier on in the file there were a
({)
? Should your new way of matching find that {? Or would the enclosing
( and ) prevent this being a match? If so, what are the exact criteria?
> Why is it a desired thing that Emacs should show some mismatching
> paren if the cursor is on a completely unrelated paren?
Emacs doesn't have the facilities to determine that the mismatching
paren is "completely unrelated". It's fairly likely to be a typo. For
example, on some keyboard layouts (including British English), ] and }
are on the same key. It's easy to mistype } as ] and not notice right
away. The show-paren-mode mismatch facility helps notice it sooner.
But, as I say, the best way to go from here would be to implement your
new matching scheme and then we can try it out. I can think of some
uses for it, for example for commands like `occur' on M-s o, where a
regexp gets entered into the minibuffer. Regexps frequently have
unmatched parens.
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2024-02-12 14:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 11:49 Parenthesis matching should consider the kind of parenthesis during pair-search Herman, Géza
2024-02-12 12:34 ` Joost Kremers
2024-02-12 12:58 ` Alan Mackenzie
2024-02-12 13:10 ` Herman, Géza
2024-02-12 14:07 ` Alan Mackenzie [this message]
2024-02-12 14:10 ` Herman, Géza
2024-02-12 15:57 ` Alan Mackenzie
2024-02-12 16:05 ` Herman, Géza
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZcomHxJHapm5-_gm@ACM \
--to=acm@muc.de \
--cc=emacs-devel@gnu.org \
--cc=geza.herman@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 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.