bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#50136: 28.0.50; A problem with rx-let expansion


From: Mattias Engdegård
Subject: bug#50136: 28.0.50; A problem with rx-let expansion
Date: Sat, 21 Aug 2021 15:02:47 +0200

21 aug. 2021 kl. 13.45 skrev Michael Heerdegen <michael_heerdegen@web.de>:

>  (let ((args (list rest))) ...)
> 
> inside rx `eval' and use that as argument list variable.

Or just put all the actual code in a plain function:

(eval-when-compile
 (defun expand-my-rx-thing (x y &optional z &rest r) ...))

(rx-define my-rx-thing (x y &rest more) (eval (expand-my-rx-thing x y more)))

and use &optional and &rest arguments as you are used to, without any risks of 
substitution accidents like "string" in the example you showed earlier. The 
function would effectively work exactly like a macro of the sort you requested.

> Maybe it would be good to improve the docstring to say the things that I
> missed clearer? - Say explicitly that this mechanism is different from
> macros, instead it's just a simple substitution mechanism, and add a
> simple example to the docstring as a reference, even if we already have
> examples in the manual.

I'll see what can be done. It's not really Emacs tradition to have examples in 
doc strings but maybe they can be improved a bit as you say.

> Maybe also tell that using `eval' you can still have a macro-like
> behavior in the end.

Not a bad idea!






reply via email to

[Prev in Thread] Current Thread [Next in Thread]