diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2022-12-04 15:20:49 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2022-12-11 16:49:06 +0100 |
commit | 87475f4af21daf8a09f08e359a22c33e0173f3ee (patch) | |
tree | 449e5f6d6e4d91052285de49e2be60b8d29c38d9 /lisp/emacs-lisp/rx.el | |
parent | 4893a15631743e1d885bd09b9184bc112c7eadcb (diff) | |
download | emacs-87475f4af21daf8a09f08e359a22c33e0173f3ee.tar.gz emacs-87475f4af21daf8a09f08e359a22c33e0173f3ee.tar.bz2 emacs-87475f4af21daf8a09f08e359a22c33e0173f3ee.zip |
Fix pcase rx patterns using rx-let bindings (bug#59814)
Reported by Daniel Pittman.
* lisp/emacs-lisp/rx.el (rx): Move binding of rx--local-definitions...
(rx--to-expr): ...here.
* test/lisp/emacs-lisp/rx-tests.el (rx-let-pcase): New test.
Diffstat (limited to 'lisp/emacs-lisp/rx.el')
-rw-r--r-- | lisp/emacs-lisp/rx.el | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index ec51146484a..f2a0dc54832 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -1152,7 +1152,12 @@ For extending the `rx' notation in FORM, use `rx-define' or `rx-let-eval'." (defun rx--to-expr (form) "Translate the rx-expression FORM to a Lisp expression yielding a regexp." - (let* ((rx--delayed-evaluation t) + (let* ((rx--local-definitions + ;; Retrieve local definitions from the macroexpansion environment. + ;; (It's unclear whether the previous value of `rx--local-definitions' + ;; should be included, and if so, in which order.) + (cdr (assq :rx-locals macroexpand-all-environment))) + (rx--delayed-evaluation t) (elems (car (rx--translate form))) (args nil)) ;; Merge adjacent strings. @@ -1282,12 +1287,7 @@ Additional constructs can be defined using `rx-define' and `rx-let', which see. \(fn REGEXPS...)" - ;; Retrieve local definitions from the macroexpansion environment. - ;; (It's unclear whether the previous value of `rx--local-definitions' - ;; should be included, and if so, in which order.) - (let ((rx--local-definitions - (cdr (assq :rx-locals macroexpand-all-environment)))) - (rx--to-expr (cons 'seq regexps)))) + (rx--to-expr (cons 'seq regexps))) (defun rx--make-binding (name tail) "Make a definitions entry out of TAIL. |