From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Scan of regexps in Emacs (March 17) Date: Tue, 19 Mar 2019 18:53:21 -0700 Organization: UCLA Computer Science Department Message-ID: <3974269b-6cad-0744-bd1f-66c067f94192@cs.ucla.edu> References: <5363970c-3207-1bb4-8b30-74a7d12277cc@cs.ucla.edu> <05269D79-B016-4FCB-94B8-068BF7D1C2D2@acm.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------3AF5E5222EB4AEA6BCFBE54B" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="135625"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 Cc: emacs-devel To: =?UTF-8?Q?Mattias_Engdeg=c3=a5rd?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 20 02:54:07 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 1h6QQe-000Z6H-C0 for ged-emacs-devel@m.gmane.org; Wed, 20 Mar 2019 02:54:04 +0100 Original-Received: from localhost ([127.0.0.1]:41152 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6QQd-0002Is-9V for ged-emacs-devel@m.gmane.org; Tue, 19 Mar 2019 21:54:03 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:43601) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h6QQM-0002Fd-Pu for emacs-devel@gnu.org; Tue, 19 Mar 2019 21:53:48 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h6QQH-0003SS-5L for emacs-devel@gnu.org; Tue, 19 Mar 2019 21:53:44 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:39216) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h6QQB-00038V-RA for emacs-devel@gnu.org; Tue, 19 Mar 2019 21:53:38 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id CD580160855; Tue, 19 Mar 2019 18:53:23 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id helMC4xlnQbp; Tue, 19 Mar 2019 18:53:22 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 6957016086D; Tue, 19 Mar 2019 18:53:22 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id QtQVH8Q50xzd; Tue, 19 Mar 2019 18:53:22 -0700 (PDT) Original-Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 34C11160827; Tue, 19 Mar 2019 18:53:22 -0700 (PDT) In-Reply-To: <05269D79-B016-4FCB-94B8-068BF7D1C2D2@acm.org> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 131.179.128.68 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:234386 Archived-At: This is a multi-part message in MIME format. --------------3AF5E5222EB4AEA6BCFBE54B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for proofreading that. I installed the attached to try to fix the problems you noted. 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, and should be avoided. Second, a regexp like [[:alnum:]-z] is also ambiguous for the same reason. 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. --------------3AF5E5222EB4AEA6BCFBE54B Content-Type: text/x-patch; name="0001-More-minor-regex-cleanup.patch" Content-Disposition: attachment; filename="0001-More-minor-regex-cleanup.patch" Content-Transfer-Encoding: quoted-printable >From e14c0d748efe35afc653151ff18c4dd93dcc456e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 19 Mar 2019 18:45:17 -0700 Subject: [PATCH] More minor regex cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit Problems reported by Mattias Engdeg=C3=A5rd in: https://lists.gnu.org/r/emacs-devel/2019-03/msg00643.html plus a few others that I noticed. * lisp/auth-source-pass.el (auth-source-pass--parse-data): * lisp/org/org-datetree.el (org-datetree--find-create): * lisp/org/org-pcomplete.el (org-thing-at-point): * lisp/progmodes/js.el (js--end-of-do-while-loop-p): * lisp/textmodes/sgml-mode.el: (sgml-electric-tag-pair-before-change-function): * lisp/textmodes/texnfo-upd.el (texinfo-menu-copy-old-description): * lisp/url/url-http.el (url-http-parse-response): Fix regular expression and similar syntax. --- lisp/auth-source-pass.el | 2 +- lisp/org/org-datetree.el | 9 +++++---- lisp/org/org-pcomplete.el | 4 ++-- lisp/progmodes/cperl-mode.el | 2 +- lisp/progmodes/js.el | 2 +- lisp/textmodes/sgml-mode.el | 7 ++++--- lisp/textmodes/texnfo-upd.el | 2 +- lisp/url/url-http.el | 2 +- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lisp/auth-source-pass.el b/lisp/auth-source-pass.el index 29ff9c6685..4283ed0392 100644 --- a/lisp/auth-source-pass.el +++ b/lisp/auth-source-pass.el @@ -139,7 +139,7 @@ auth-source-pass--parse-secret (defun auth-source-pass--parse-data (contents) "Parse the password-store data in the string CONTENTS and return an al= ist. CONTENTS is the contents of a password-store formatted file." - (let ((lines (split-string contents "\n" t "\\\s"))) + (let ((lines (split-string contents "\n" t "[ \t]+"))) (seq-remove #'null (mapcar (lambda (line) (let ((pair (mapcar (lambda (s) (string-trim s= )) diff --git a/lisp/org/org-datetree.el b/lisp/org/org-datetree.el index aea2c8d3d6..b4797de1e5 100644 --- a/lisp/org/org-datetree.el +++ b/lisp/org/org-datetree.el @@ -138,15 +138,16 @@ org-datetree-find-iso-week-create "^\\*+[ \t]+%d-%02d-\\([0123][0-9]\\) \\w+$" year month day)))) =20 -(defun org-datetree--find-create (regex year &optional month day insert) - "Find the datetree matched by REGEX for YEAR, MONTH, or DAY. -REGEX is passed to `format' with YEAR, MONTH, and DAY as +(defun org-datetree--find-create + (regex-template year &optional month day insert) + "Find the datetree matched by REGEX-TEMPLATE for YEAR, MONTH, or DAY. +REGEX-TEMPLATE is passed to `format' with YEAR, MONTH, and DAY as arguments. Match group 1 is compared against the specified date component. If INSERT is non-nil and there is no match then it is inserted into the buffer." (when (or month day) (org-narrow-to-subtree)) - (let ((re (format regex year month day)) + (let ((re (format regex-template year month day)) match) (goto-char (point-min)) (while (and (setq match (re-search-forward re nil t)) diff --git a/lisp/org/org-pcomplete.el b/lisp/org/org-pcomplete.el index 49983c40a5..cf272de90a 100644 --- a/lisp/org/org-pcomplete.el +++ b/lisp/org/org-pcomplete.el @@ -49,10 +49,10 @@ org-thing-at-point "Examine the thing at point and let the caller know what it is. The return value is a string naming the thing at point." (let ((beg1 (save-excursion - (skip-chars-backward "[:alnum:]-_@") + (skip-chars-backward "-[:alnum:]_@") (point))) (beg (save-excursion - (skip-chars-backward "a-zA-Z0-9-_:$") + (skip-chars-backward "-a-zA-Z0-9_:$") (point))) (line-to-here (buffer-substring (point-at-bol) (point)))) (cond diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 0b6008a511..73b55e29a5 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -1884,7 +1884,7 @@ cperl-comment-indent ;;Point is at start of real comment." ;; (let ((c (current-column)) target cnt prevc) ;; (if (=3D c comment-column) nil -;; (setq cnt (skip-chars-backward "[ \t]")) +;; (setq cnt (skip-chars-backward " \t")) ;; (setq target (max (1+ (setq prevc ;; (current-column))) ; Else indent at comment column ;; comment-column)) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index f1ec5ceea5..4d91da7334 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -1908,7 +1908,7 @@ js--end-of-do-while-loop-p (save-match-data (when (looking-at "\\s-*\\_") (if (save-excursion - (skip-chars-backward "[ \t\n]*}") + (skip-chars-backward " \t\n}") (looking-at "[ \t\n]*}")) (save-excursion (backward-list) (forward-symbol -1) (looking-at "\\_")) diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index e49144e290..9e3be99af1 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -894,7 +894,7 @@ sgml-electric-tag-pair-before-change-function (condition-case err (save-excursion (goto-char end) - (skip-chars-backward "[:alnum:]-_.:") + (skip-chars-backward "-[:alnum:]_.:") (if (and ;; (<=3D (point) beg) ; This poses problems for downcase-wo= rd. (or (eq (char-before) ?<) (and (eq (char-before) ?/) @@ -902,7 +902,7 @@ sgml-electric-tag-pair-before-change-function (null (get-char-property (point) 'text-clones))) (let* ((endp (eq (char-before) ?/)) (cl-start (point)) - (cl-end (progn (skip-chars-forward "[:alnum:]-_.:") (poin= t))) + (cl-end (progn (skip-chars-forward "-[:alnum:]_.:") (point))) (match (if endp (when (sgml-skip-tag-backward 1) (forward-char 1) t) @@ -919,7 +919,8 @@ sgml-electric-tag-pair-before-change-function (equal (buffer-substring cl-start cl-end) (buffer-substring (point) (save-excursion - (skip-chars-forward "[:a= lnum:]-_.:") + (skip-chars-forward + "-[:alnum:]_.:") (point)))) (or (not endp) (eq (char-after cl-end) ?>))) (when clones diff --git a/lisp/textmodes/texnfo-upd.el b/lisp/textmodes/texnfo-upd.el index 8c6e23eae4..e960e992a8 100644 --- a/lisp/textmodes/texnfo-upd.el +++ b/lisp/textmodes/texnfo-upd.el @@ -642,7 +642,7 @@ texinfo-menu-copy-old-description "Return description field of old menu line as string. Point must be located just after the node name. Point left before descr= iption. Single argument, END-OF-MENU, is position limiting search." - (skip-chars-forward "[:.,\t\n ]+") + (skip-chars-forward ":.,\t\n ") ;; don't copy a carriage return at line beginning with asterisk! ;; don't copy @detailmenu or @end menu or @ignore as descriptions! ;; do copy a description that begins with an `@'! diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 46baa8a148..1fbc087073 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -517,7 +517,7 @@ url-http-parse-response (setq url-http-response-version (buffer-substring (point) (progn - (skip-chars-forward "[0-9].") + (skip-chars-forward "0-9.") (point)))) (setq url-http-response-status (read (current-buffer)))) =20 --=20 2.17.1 --------------3AF5E5222EB4AEA6BCFBE54B--