Expand rx definitions inside (not ...)

* lisp/emacs-lisp/rx.el (rx--translate-not):
* test/lisp/emacs-lisp/rx-tests.el (rx-not, rx-def-in-not):
* doc/lispref/searching.texi (Rx Constructs, Extending Rx):

Allow user-defined rx constructs to be expanded inside (not ...)
forms, for better composability (bug#37849).
This commit is contained in:
Mattias Engdegård 2019-10-27 09:54:54 +01:00
parent 6e66d9a95c
commit cbd439e785
3 changed files with 21 additions and 3 deletions

View file

@ -477,6 +477,9 @@ If NEGATED, negate the sense (thus making it positive)."
((eq arg 'word-boundary)
(rx--translate-symbol
(if negated 'word-boundary 'not-word-boundary)))
((let ((expanded (rx--expand-def arg)))
(and expanded
(rx--translate-not negated (list expanded)))))
(t (error "Illegal argument to rx `not': %S" arg)))))
(defun rx--atomic-regexp (item)