From cbd439e785cd1e72c3eae39ed987fda357014bf8 Mon Sep 17 00:00:00 2001 From: Mattias EngdegÄrd Date: Sun, 27 Oct 2019 09:54:54 +0100 Subject: 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). --- lisp/emacs-lisp/rx.el | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index d7677f14443..52a35ffa2a7 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -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) -- cgit v1.2.3