Make the rx eval
form use lexical binding when active
Previously, it always used dynamic binding. * lisp/emacs-lisp/rx.el (rx--expand-eval): Heed `lexical-binding`. * test/lisp/emacs-lisp/rx-tests.el (rx-tests--x, rx-tests--get-x) (rx-eval): Add test case. * etc/NEWS: Announce.
This commit is contained in:
parent
ba6779ab2a
commit
89f88f06a4
3 changed files with 13 additions and 2 deletions
4
etc/NEWS
4
etc/NEWS
|
@ -1280,6 +1280,10 @@ name. Previously, Eshell only did this for MS-Windows systems. To
|
|||
restore the old behavior, you can set 'eshell-pwd-convert-function' to
|
||||
'identity'.
|
||||
|
||||
---
|
||||
** The rx 'eval' form now uses the current elisp dialect for evaluation.
|
||||
Previously, its argument was always evaluated using dynamic binding.
|
||||
|
||||
|
||||
* Lisp Changes in Emacs 31.1
|
||||
|
||||
|
|
|
@ -1072,7 +1072,7 @@ Return (REGEXP . PRECEDENCE)."
|
|||
"Expand `eval' arguments. Return a new rx form."
|
||||
(unless (and body (null (cdr body)))
|
||||
(error "rx `eval' form takes exactly one argument"))
|
||||
(eval (car body)))
|
||||
(eval (car body) lexical-binding))
|
||||
|
||||
(defun rx--translate-eval (body)
|
||||
"Translate the `eval' form. Return (REGEXP . PRECEDENCE)."
|
||||
|
|
|
@ -485,11 +485,18 @@
|
|||
(should (equal (rx "" (regexp x) (eval ""))
|
||||
"a*"))))
|
||||
|
||||
(eval-when-compile
|
||||
(defvar rx-tests--x "LEX")
|
||||
(defun rx-tests--get-x () rx-tests--x))
|
||||
|
||||
(ert-deftest rx-eval ()
|
||||
(should (equal (rx (eval (list 'syntax 'symbol)))
|
||||
"\\s_"))
|
||||
(should (equal (rx "a" (eval (concat)) "b")
|
||||
"ab")))
|
||||
"ab"))
|
||||
(should (equal (rx (eval (funcall (lambda (rx-tests--x) (rx-tests--get-x))
|
||||
"DYN")))
|
||||
"LEX")))
|
||||
|
||||
(ert-deftest rx-literal ()
|
||||
(should (equal (rx (literal "$a"))
|
||||
|
|
Loading…
Add table
Reference in a new issue