diff options
| author | Mattias EngdegÄrd | 2019-10-07 18:07:16 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2019-10-18 14:45:47 +0200 |
| commit | e5a446b0a706ddd4bedf973baeaf54f105198b09 (patch) | |
| tree | 64c299b5c279b8acd257c0a964a4d183c68e8315 | |
| parent | 2d13a3f68d4724af52e47675bedf60709c7b5171 (diff) | |
| download | emacs-e5a446b0a706ddd4bedf973baeaf54f105198b09.tar.gz emacs-e5a446b0a706ddd4bedf973baeaf54f105198b09.zip | |
Add `anychar' as alias to `anything' in rx (bug#37659)
* lisp/emacs-lisp/rx.el (rx--translate-symbol, rx--builtin-symbols, rx):
* test/lisp/emacs-lisp/rx-tests.el (rx-atoms):
* doc/lispref/searching.texi (Rx Constructs):
* etc/NEWS:
Add `anychar', an alias for `anything'. Since `anychar' is more
descriptive (and slightly shorter), treat it as the preferred name.
| -rw-r--r-- | doc/lispref/searching.texi | 3 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/emacs-lisp/rx.el | 7 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/rx-tests.el | 4 |
4 files changed, 11 insertions, 7 deletions
diff --git a/doc/lispref/searching.texi b/doc/lispref/searching.texi index a4b65334126..2274bab002c 100644 --- a/doc/lispref/searching.texi +++ b/doc/lispref/searching.texi | |||
| @@ -1220,7 +1220,8 @@ Corresponding string regexp: @samp{[^@dots{}]}, @samp{\S@var{code}}, | |||
| 1220 | Match any character except a newline.@* | 1220 | Match any character except a newline.@* |
| 1221 | Corresponding string regexp: @samp{.} (dot) | 1221 | Corresponding string regexp: @samp{.} (dot) |
| 1222 | 1222 | ||
| 1223 | @item @code{anything} | 1223 | @item @code{anychar}, @code{anything} |
| 1224 | @cindex @code{anychar} in rx | ||
| 1224 | @cindex @code{anything} in rx | 1225 | @cindex @code{anything} in rx |
| 1225 | Match any character.@* | 1226 | Match any character.@* |
| 1226 | Corresponding string regexp: @samp{.\|\n} (for example) | 1227 | Corresponding string regexp: @samp{.\|\n} (for example) |
| @@ -1854,6 +1854,10 @@ at run time, instead of a constant string. | |||
| 1854 | *** New rx extension mechanism: 'rx-define', 'rx-let', 'rx-let-eval'. | 1854 | *** New rx extension mechanism: 'rx-define', 'rx-let', 'rx-let-eval'. |
| 1855 | These macros add new forms to the rx notation. | 1855 | These macros add new forms to the rx notation. |
| 1856 | 1856 | ||
| 1857 | +++ | ||
| 1858 | *** 'anychar' is now an alias for 'anything' | ||
| 1859 | Both match any single character; 'anychar' is more descriptive. | ||
| 1860 | |||
| 1857 | ** Frames | 1861 | ** Frames |
| 1858 | 1862 | ||
| 1859 | +++ | 1863 | +++ |
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index 45fec796cc3..6c0b2069302 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el | |||
| @@ -126,7 +126,6 @@ Each entry is: | |||
| 126 | (get name 'rx-definition))) | 126 | (get name 'rx-definition))) |
| 127 | 127 | ||
| 128 | ;; TODO: Additions to consider: | 128 | ;; TODO: Additions to consider: |
| 129 | ;; - A better name for `anything', like `any-char' or `anychar'. | ||
| 130 | ;; - A name for (or), maybe `unmatchable'. | 129 | ;; - A name for (or), maybe `unmatchable'. |
| 131 | ;; - A construct like `or' but without the match order guarantee, | 130 | ;; - A construct like `or' but without the match order guarantee, |
| 132 | ;; maybe `unordered-or'. Useful for composition or generation of | 131 | ;; maybe `unordered-or'. Useful for composition or generation of |
| @@ -138,7 +137,7 @@ Each entry is: | |||
| 138 | ;; Use `list' instead of a quoted list to wrap the strings here, | 137 | ;; Use `list' instead of a quoted list to wrap the strings here, |
| 139 | ;; since the return value may be mutated. | 138 | ;; since the return value may be mutated. |
| 140 | ((or 'nonl 'not-newline 'any) (cons (list ".") t)) | 139 | ((or 'nonl 'not-newline 'any) (cons (list ".") t)) |
| 141 | ('anything (rx--translate-form '(or nonl "\n"))) | 140 | ((or 'anychar 'anything) (rx--translate-form '(or nonl "\n"))) |
| 142 | ((or 'bol 'line-start) (cons (list "^") 'lseq)) | 141 | ((or 'bol 'line-start) (cons (list "^") 'lseq)) |
| 143 | ((or 'eol 'line-end) (cons (list "$") 'rseq)) | 142 | ((or 'eol 'line-end) (cons (list "$") 'rseq)) |
| 144 | ((or 'bos 'string-start 'bot 'buffer-start) (cons (list "\\`") t)) | 143 | ((or 'bos 'string-start 'bot 'buffer-start) (cons (list "\\`") t)) |
| @@ -913,7 +912,7 @@ can expand to any number of values." | |||
| 913 | "List of built-in rx function-like symbols.") | 912 | "List of built-in rx function-like symbols.") |
| 914 | 913 | ||
| 915 | (defconst rx--builtin-symbols | 914 | (defconst rx--builtin-symbols |
| 916 | (append '(nonl not-newline any anything | 915 | (append '(nonl not-newline any anychar anything |
| 917 | bol eol line-start line-end | 916 | bol eol line-start line-end |
| 918 | bos eos string-start string-end | 917 | bos eos string-start string-end |
| 919 | bow eow word-start word-end | 918 | bow eow word-start word-end |
| @@ -1016,7 +1015,7 @@ CHAR Match a literal character. | |||
| 1016 | can be (any ...), (syntax ...), (category ...), | 1015 | can be (any ...), (syntax ...), (category ...), |
| 1017 | or a character class. | 1016 | or a character class. |
| 1018 | not-newline Match any character except a newline. Alias: nonl. | 1017 | not-newline Match any character except a newline. Alias: nonl. |
| 1019 | anything Match any character. | 1018 | anychar Match any character. Alias: anything. |
| 1020 | 1019 | ||
| 1021 | CHARCLASS Match a character from a character class. One of: | 1020 | CHARCLASS Match a character from a character class. One of: |
| 1022 | alpha, alphabetic, letter Alphabetic characters (defined by Unicode). | 1021 | alpha, alphabetic, letter Alphabetic characters (defined by Unicode). |
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 76dcf419428..d4524e5a251 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el | |||
| @@ -184,8 +184,8 @@ | |||
| 184 | "ab"))) | 184 | "ab"))) |
| 185 | 185 | ||
| 186 | (ert-deftest rx-atoms () | 186 | (ert-deftest rx-atoms () |
| 187 | (should (equal (rx anything) | 187 | (should (equal (rx anychar anything) |
| 188 | ".\\|\n")) | 188 | "\\(?:.\\|\n\\)\\(?:.\\|\n\\)")) |
| 189 | (should (equal (rx line-start not-newline nonl any line-end) | 189 | (should (equal (rx line-start not-newline nonl any line-end) |
| 190 | "^...$")) | 190 | "^...$")) |
| 191 | (should (equal (rx bol string-start string-end buffer-start buffer-end | 191 | (should (equal (rx bol string-start string-end buffer-start buffer-end |