diff options
| author | Mattias EngdegÄrd | 2020-03-05 12:49:26 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2020-03-05 12:55:54 +0100 |
| commit | 1814c7e158685045278f991de5eba4e40e8c8199 (patch) | |
| tree | d5410f610b70f28207b617bfb793067d36808207 | |
| parent | 40fb20061e6b9b2b22aeee5b7e9f038dc9ba843b (diff) | |
| download | emacs-1814c7e158685045278f991de5eba4e40e8c8199.tar.gz emacs-1814c7e158685045278f991de5eba4e40e8c8199.zip | |
Fix rx error with ? and ??
The ? and ?? rx operators are special in that they can be written as
characters (space and '?' respectively). This confused the definition
look-up mechanism in rare cases.
* lisp/emacs-lisp/rx.el (rx--expand-def): Don't look up non-symbols.
* test/lisp/emacs-lisp/rx-tests.el (rx-charset-or): Test.
| -rw-r--r-- | lisp/emacs-lisp/rx.el | 2 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/rx-tests.el | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index d4a91710273..aa4b2addd47 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el | |||
| @@ -134,7 +134,7 @@ Each entry is: | |||
| 134 | (if (cdr def) | 134 | (if (cdr def) |
| 135 | (error "Not an `rx' symbol definition: %s" form) | 135 | (error "Not an `rx' symbol definition: %s" form) |
| 136 | (car def))))) | 136 | (car def))))) |
| 137 | ((consp form) | 137 | ((and (consp form) (symbolp (car form))) |
| 138 | (let* ((op (car form)) | 138 | (let* ((op (car form)) |
| 139 | (def (rx--lookup-def op))) | 139 | (def (rx--lookup-def op))) |
| 140 | (and def | 140 | (and def |
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 4888e1d9d1e..0fece4004bd 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el | |||
| @@ -316,7 +316,9 @@ | |||
| 316 | (should (equal (rx (not (or (in "abc") (char "bcd")))) | 316 | (should (equal (rx (not (or (in "abc") (char "bcd")))) |
| 317 | "[^a-d]")) | 317 | "[^a-d]")) |
| 318 | (should (equal (rx (or (not (in "abc")) (not (char "bcd")))) | 318 | (should (equal (rx (or (not (in "abc")) (not (char "bcd")))) |
| 319 | "[^bc]"))) | 319 | "[^bc]")) |
| 320 | (should (equal (rx (or "x" (? "yz"))) | ||
| 321 | "x\\|\\(?:yz\\)?"))) | ||
| 320 | 322 | ||
| 321 | (ert-deftest rx-def-in-charset-or () | 323 | (ert-deftest rx-def-in-charset-or () |
| 322 | (rx-let ((a (any "badc")) | 324 | (rx-let ((a (any "badc")) |