diff options
| author | Noam Postavsky | 2019-06-14 08:43:17 -0400 |
|---|---|---|
| committer | Noam Postavsky | 2019-06-25 22:00:03 -0400 |
| commit | b59ffd2290ff744ca4e7cc2748ba6b66fb2f99f1 (patch) | |
| tree | 650ab12b77ba2cf9918ebc9bce586ce22ab7d52a /etc | |
| parent | 29babad7286bff235407e883a4ff61bae49a2e5e (diff) | |
| download | emacs-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/NEWS | 6 |
1 files changed, 6 insertions, 0 deletions
| @@ -1441,12 +1441,18 @@ when given in a string. Previously, '(any "\x80-\xff")' would match | |||
| 1441 | characters U+0080...U+00FF. Now the expression matches raw bytes in | 1441 | characters U+0080...U+00FF. Now the expression matches raw bytes in |
| 1442 | the 128...255 range, as expected. | 1442 | the 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) |
| 1446 | matches the empty string, each being an identity for the operation. | 1447 | matches the empty string, each being an identity for the operation. |
| 1447 | This also works for their aliases: '|' for 'or'; ':', 'and' and | 1448 | This 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. | ||
| 1453 | In this case, 'rx' will generate code which produces a regexp string | ||
| 1454 | at run time, instead of a constant string. | ||
| 1455 | |||
| 1450 | ** Frames | 1456 | ** Frames |
| 1451 | 1457 | ||
| 1452 | +++ | 1458 | +++ |