From: Joe Riel <jriel@maplesoft.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Match empty string at begin/end of symbol
Date: Wed, 4 Jul 2018 12:37:35 -0700 [thread overview]
Message-ID: <20180704123735.1c83ac80@gauss> (raw)
In-Reply-To: <83zhz6n6vs.fsf@gnu.org>
On Wed, 04 Jul 2018 22:22:15 +0300
Eli Zaretskii <eliz@gnu.org> wrote:
> > Date: Wed, 4 Jul 2018 11:43:46 -0700
> > From: Joe Riel <joer@san.rr.com>
> >
> > The regular expressions '\_<' and '\_>'
> > seem to be broken in Emacs 25.1.1. Consider
> >
> > (let ((str "3+ab"))
> > (and (string-match "\\<[a-zA-Z][a-zA-Z0-9]*" str)
> > (match-string 0 str)))
> >
> > That returns "ab", as expected. Change the "\\<" to "\\_<"
> > and it no longer matches. Why not?
> >
> > (let ((str "3+ab"))
> > (and (string-match "\\_<[a-zA-Z][a-zA-Z0-9]*" str)
> > (match-string 0 str)))
>
> The result of the last form depends on the major mode of the buffer
> where (or in whose minibuffer) you evaluate it. If it's Lisp or its
> derivatives, it indeed should not match because a Lisp symbol can
> legitimately be named "3+ab", and so "ab" is not at a symbol
> boundary. But if you try the same in a buffer whose major mode is C
> Mode, you surely get a match, because '+' is not a symbol-constituent
> character in C.
>
> IOW, I don't think there's a bug here. It's behaving as intended.
>
Thanks, Eli. I verified that by wrapping the call in a with-syntax-table
environment set to the appropriate syntax table; all is well.
--
Joe Riel
next prev parent reply other threads:[~2018-07-04 19:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 18:43 Match empty string at begin/end of symbol Joe Riel
2018-07-04 19:21 ` Noam Postavsky
2018-07-04 19:22 ` Eli Zaretskii
2018-07-04 19:37 ` Joe Riel [this message]
2018-07-04 19:25 ` Teemu Likonen
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=20180704123735.1c83ac80@gauss \
--to=jriel@maplesoft.com \
--cc=eliz@gnu.org \
--cc=help-gnu-emacs@gnu.org \
/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.
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).