(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.
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.
(list 'ok z))
'(ok "F"))))
+(ert-deftest rx-let-pcase ()
+ "Test `rx-let' around `pcase' with `rx' patterns (bug#59814)."
+ (should (equal (rx-let ((tata "ab"))
+ (pcase "abc" ((rx tata) 'toto)))
+ 'toto)))
+
(ert-deftest rx-kleene ()
"Test greedy and non-greedy repetition operators."
(should (equal (rx (* "a") (+ "b") (\? "c") (?\s "d")