From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Scan of regexps in Emacs (March 17) Date: Tue, 19 Mar 2019 22:20:53 -0400 Message-ID: References: <5363970c-3207-1bb4-8b30-74a7d12277cc@cs.ucla.edu> <05269D79-B016-4FCB-94B8-068BF7D1C2D2@acm.org> <3974269b-6cad-0744-bd1f-66c067f94192@cs.ucla.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="40724"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 20 03:37:36 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h6R6k-000ASW-W4 for ged-emacs-devel@m.gmane.org; Wed, 20 Mar 2019 03:37:35 +0100 Original-Received: from localhost ([127.0.0.1]:41697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6R6k-0002i0-1Z for ged-emacs-devel@m.gmane.org; Tue, 19 Mar 2019 22:37:34 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6R4S-0001ft-F9 for emacs-devel@gnu.org; Tue, 19 Mar 2019 22:35:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6Qr8-0006lq-H7 for emacs-devel@gnu.org; Tue, 19 Mar 2019 22:21:29 -0400 Original-Received: from [195.159.176.226] (port=51454 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6Qqk-0006AL-Ej for emacs-devel@gnu.org; Tue, 19 Mar 2019 22:21:19 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1h6Qqi-0010tI-91 for emacs-devel@gnu.org; Wed, 20 Mar 2019 03:21:00 +0100 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:ZAbeYdXQJCIONVTTVSc+ztPdaro= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:234391 Archived-At: > I also fixed a couple of other problems if I happened to run across > them. First, the regexp [a-b-c] is ambiguous according to POSIX, Maybe according to POSIX, but not according to Emacs Lisp's reference manual: To include a ‘]’ in a character alternative, you must make it the first character. For example, ‘[]a]’ matches ‘]’ or ‘a’. To include a ‘-’, write ‘-’ as the first or last character of the character alternative, or put it after a range. Thus, ‘[]-]’ matches both ‘]’ and ‘-’. (As explained below, you cannot use ‘\]’ to include a ‘]’ inside a character alternative, since ‘\’ is not special there.) > and should be avoided. Maybe I could go along with that. [ I wish Elisp regexps just used \ as an escape char in ranges instead of relying on those special convention of where `-` and `]` can appear in order to count as themselves. ] > Second, a regexp like [[:alnum:]-z] is also ambiguous for the > same reason. I think the doc above was written for we had those char classes, but if [a-b-c] is not ambiguous then I think it's only natural to declare that [[:alnum:]-z] is not ambiguous either. > Perhaps these regexps currently have a particular behavior in > Emacs but it's not documented as far as I know and code should avoid > them. Perhaps the trawler could be modified to catch them. I wonder why the doc doesn't just say that `-` should be the last character and not mention the other possibilities which just make the rule unnecessarily complex. Stefan