I want to define a new rx
to use within another rx
definition, like so:
(defconst my-word
(rx (or word "*")))
(defconst my-regex
(rx (1+ my-word)))
However, this code returns the following error:
Eager macro-expansion failure: (error "Unknown rx symbol 'my-word'")
The solution, as per rx
documentation, is to define your rx
with rx-define
:
(rx-define my-word
(or word "*"))
(defconst my-regex
(rx (1+ my-word)))
I suspect this has something to do with the sequence of how Emacs loads symbols, but I was just curious as to the specifics of this.