X-Debbugs-CC: Kévin Le Gouguec , Stefan Monnier Severity: wishlist Tags: patch Currently, if you want to construct a regexp which includes a runtime values using rx, there are two options: - Use the (eval FORM) subform. But if using using the rx macro, FORM is evaluated at macroexpansion time, which is awkward. If using rx-to-string, then FORM can't access the lexical environment, which is also awkward. - Build a list at runtime and pass to rx-to-string. This requires the whole rx translation infrastructure at runtime, which is sad. The patch below allows the rx macro to generate a concat expression instead of just a plain string. So the example from https://debbugs.gnu.org/35564#53 would become (let ((start (max 0 (1- pos))) (char (string (aref command pos)))) ; need string for `regexp-quote'. (and (string-match (rx (or (seq (or bos blank) (group-n 1 (regexp-quote char)) (or eos blank)) (seq ?` (group-n 1 (regexp-quote char)) ?`))) command start) (= pos (match-beginning 1)))) The rx call in the above macroexpands into: (concat "\\(?:\\`\\|[[:blank:]]\\)" "\\(?" "1" ":" (regexp-quote char) "\\)" "\\(?:\\'\\|[[:blank:]]\\)" "\\|" "`" "\\(?" "1" ":" (regexp-quote char) "\\)" "`") Which will be optimal once we apply the patch from #14769 "optimize `concat's literals".