aboutsummaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorNoam Postavsky2019-06-14 08:43:17 -0400
committerNoam Postavsky2019-06-25 22:00:03 -0400
commitb59ffd2290ff744ca4e7cc2748ba6b66fb2f99f1 (patch)
tree650ab12b77ba2cf9918ebc9bce586ce22ab7d52a /etc
parent29babad7286bff235407e883a4ff61bae49a2e5e (diff)
downloademacs-b59ffd2290ff744ca4e7cc2748ba6b66fb2f99f1.tar.gz
emacs-b59ffd2290ff744ca4e7cc2748ba6b66fb2f99f1.zip
Support (rx (and (regexp EXPR) (literal EXPR))) (Bug#36237)
* lisp/emacs-lisp/rx.el (rx-regexp): Allow non-string forms. (rx-constituents): Add literal constituent, which is like a plain STRING form, but allows arbitrary lisp expressions. (rx-literal): New function. (rx-compile-to-lisp): New variable. (rx--subforms): New helper function for handling subforms, including non-constant case. (rx-group-if, rx-and, rx-or, rx-=, rx->=, rx-repeat, rx-submatch) (rx-submatch-n, rx-kleene, rx-atomic-p): Use it to handle non-constant subforms. (rx): Document new form, wrap non-constant forms with concat call. * test/lisp/emacs-lisp/rx-tests.el (rx-tests--match): New macro. (rx-nonstring-expr, rx-nonstring-expr-non-greedy): New tests. * etc/NEWS: Announce changes.
Diffstat (limited to 'etc')
-rw-r--r--etc/NEWS6
1 files changed, 6 insertions, 0 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 7de94a7b11d..29b74ee682b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1441,12 +1441,18 @@ when given in a string. Previously, '(any "\x80-\xff")' would match
1441characters U+0080...U+00FF. Now the expression matches raw bytes in 1441characters U+0080...U+00FF. Now the expression matches raw bytes in
1442the 128...255 range, as expected. 1442the 128...255 range, as expected.
1443 1443
1444---
1444*** The rx 'or' and 'seq' forms no longer require any arguments. 1445*** The rx 'or' and 'seq' forms no longer require any arguments.
1445(or) produces a regexp that never matches anything, while (seq) 1446(or) produces a regexp that never matches anything, while (seq)
1446matches the empty string, each being an identity for the operation. 1447matches the empty string, each being an identity for the operation.
1447This also works for their aliases: '|' for 'or'; ':', 'and' and 1448This also works for their aliases: '|' for 'or'; ':', 'and' and
1448'sequence' for 'seq'. 1449'sequence' for 'seq'.
1449 1450
1451---
1452*** 'regexp' and new 'literal' accept arbitrary lisp as arguments.
1453In this case, 'rx' will generate code which produces a regexp string
1454at run time, instead of a constant string.
1455
1450** Frames 1456** Frames
1451 1457
1452+++ 1458+++