From: Mattias EngdegÄrd Date: Tue, 30 May 2023 08:04:48 +0000 (+0200) Subject: Avoid using rx `any` for `not-newline` X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=ace9f6775580459c35254607d866f3bb22a8c45b;p=emacs.git Avoid using rx `any` for `not-newline` Despite its name, `any` does not match any character (use `anychar` for that) but is an old synonym for `not-newline` and `nonl`, retained for compatibility with the obsolete `sregex` package. (In SRE as defined by SRFI-115, `any` does match any character.) There is also a mild but unnecessary confusion with the more frequently used `any` construct for character alternatives. * lisp/edmacro.el (edmacro-mode-font-lock-keywords): * lisp/erc/erc.el (erc--ensure-url): * lisp/org/org.el (org-fontify-meta-lines-and-blocks-1): * lisp/progmodes/scheme.el (scheme-imenu-generic-expression): * test/lisp/find-cmd-tests.el (find-cmd-test-find-cmd): Replace uses of `any` with `nonl`. --- diff --git a/lisp/edmacro.el b/lisp/edmacro.el index 8734f7cbebe..69d20d2bad3 100644 --- a/lisp/edmacro.el +++ b/lisp/edmacro.el @@ -91,17 +91,17 @@ Default nil means to write characters above \\177 in octal notation." `((,(rx bol (group (or "Command" "Key" "Macro") ":")) 0 'edmacro-label) (,(rx bol (group ";; Keyboard Macro Editor. Press ") - (group (*? any)) + (group (*? nonl)) (group " to finish; press ")) (1 'font-lock-comment-face) (2 'help-key-binding) (3 'font-lock-comment-face) - (,(rx (group (*? any)) - (group " to cancel" (* any))) + (,(rx (group (*? nonl)) + (group " to cancel" (* nonl))) nil nil (1 'help-key-binding) (2 'font-lock-comment-face))) - (,(rx (one-or-more ";") (zero-or-more any)) 0 'font-lock-comment-face))) + (,(rx (one-or-more ";") (zero-or-more nonl)) 0 'font-lock-comment-face))) (defvar edmacro-store-hook) (defvar edmacro-finish-hook) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 5a91285c1d1..2c2df81fa6d 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -2398,9 +2398,9 @@ parameters SERVER and NICK." (defun erc--ensure-url (input) (unless (string-match (rx bot "irc" (? "6") (? "s") "://") input) - (when (and (string-match (rx (? (+ any) "@") - (or (group (* (not "[")) ":" (* any)) - (+ any)) + (when (and (string-match (rx (? (+ nonl) "@") + (or (group (* (not "[")) ":" (* nonl)) + (+ nonl)) ":" (+ (not (any ":]"))) eot) input) (match-beginning 1)) diff --git a/lisp/org/org.el b/lisp/org/org.el index e42704778bd..b81630fdc07 100644 --- a/lisp/org/org.el +++ b/lisp/org/org.el @@ -5374,7 +5374,7 @@ by a #." (zero-or-more (any " \t")) (group (group (zero-or-more (not (any " \t\n")))) (zero-or-more (any " \t")) - (group (zero-or-more any))))) + (group (zero-or-more nonl))))) limit t) (let ((beg (match-beginning 0)) (end-of-beginline (match-end 0)) @@ -5400,7 +5400,7 @@ by a #." "#+end" ,(match-string 4) word-end - (zero-or-more any))))) + (zero-or-more nonl))))) ;; We look further than LIMIT on purpose. nil t) ;; We do have a matching #+end line. @@ -5473,7 +5473,7 @@ by a #." (beginning-of-line) (looking-at (rx (group (zero-or-more (any " \t")) "#+caption" - (optional "[" (zero-or-more any) "]") + (optional "[" (zero-or-more nonl) "]") ":") (zero-or-more (any " \t"))))) (add-text-properties (line-beginning-position) (match-end 1) diff --git a/lisp/progmodes/scheme.el b/lisp/progmodes/scheme.el index 38cb19f5a12..e6fcc684729 100644 --- a/lisp/progmodes/scheme.el +++ b/lisp/progmodes/scheme.el @@ -155,7 +155,7 @@ ,(rx bol (zero-or-more space) "(define-module" (one-or-more space) - (group "(" (one-or-more any) ")")) + (group "(" (one-or-more nonl) ")")) 1) ("Macros" ,(rx bol (zero-or-more space) "(" diff --git a/test/lisp/find-cmd-tests.el b/test/lisp/find-cmd-tests.el index a0b9a80ef47..3fbd0fc4ea3 100644 --- a/test/lisp/find-cmd-tests.el +++ b/test/lisp/find-cmd-tests.el @@ -25,7 +25,7 @@ (ert-deftest find-cmd-test-find-cmd () (should (string-match - (rx "find " (+ any) + (rx "find " (+ nonl) " \\( \\( -name .svn -or -name .git -or -name .CVS \\)" " -prune -or -true \\)" " \\( \\( \\(" " -name \\*.pl -or -name \\*.pm -or -name \\*.t \\)"