From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Joe Riel Newsgroups: gmane.emacs.help Subject: Re: Match empty string at begin/end of symbol Date: Wed, 4 Jul 2018 12:37:35 -0700 Organization: Maplesoft Message-ID: <20180704123735.1c83ac80@gauss> References: <20180704114346.73df0142@gauss> <83zhz6n6vs.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1530740078 25304 195.159.176.226 (4 Jul 2018 21:34:38 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 4 Jul 2018 21:34:38 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jul 04 23:34:34 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fapQ0-0006SR-GQ for geh-help-gnu-emacs@m.gmane.org; Wed, 04 Jul 2018 23:34:32 +0200 Original-Received: from localhost ([::1]:49310 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fapS7-0000C7-CM for geh-help-gnu-emacs@m.gmane.org; Wed, 04 Jul 2018 17:36:43 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fao4J-0007qW-Ps for help-gnu-emacs@gnu.org; Wed, 04 Jul 2018 16:08:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fao4E-0002tn-Pv for help-gnu-emacs@gnu.org; Wed, 04 Jul 2018 16:08:03 -0400 Original-Received: from mh3.maplesoft.com ([199.71.183.16]:62974 helo=ICW12KMAI02.maplesoft.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fao4E-0002tC-Iw; Wed, 04 Jul 2018 16:07:58 -0400 Original-Received: from ICW12KMAI02.maplesoft.com (10.10.1.102) by ICW12KMAI02.maplesoft.com (10.10.1.102) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 4 Jul 2018 15:37:37 -0400 Original-Received: from gauss (10.10.50.100) by ICW12KMAI02.maplesoft.com (10.10.1.102) with Microsoft SMTP Server (TLS) id 15.0.1347.2 via Frontend Transport; Wed, 4 Jul 2018 15:37:36 -0400 In-Reply-To: <83zhz6n6vs.fsf@gnu.org> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 199.71.183.16 X-Mailman-Approved-At: Wed, 04 Jul 2018 17:36:16 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:117350 Archived-At: On Wed, 04 Jul 2018 22:22:15 +0300 Eli Zaretskii wrote: > > Date: Wed, 4 Jul 2018 11:43:46 -0700 > > From: Joe Riel > > > > 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