emacs-devel
[Top][All Lists]
Advanced

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

Re: Make format-spec accept a function as the substitution


From: Philip Kaludercic
Subject: Re: Make format-spec accept a function as the substitution
Date: Thu, 29 Sep 2022 15:02:56 +0000

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> Thierry Volpiatto [2022-09-29 06:57:07] wrote:
>> After thinking at it, it would be great to allow using interactive calls
>> in specs without wrapping them inside a function:
>>
>> Using this should ask for line number and file:
>> (format-spec "Go to line %n in file %f %g" '((?n . (read-number "Number: "))
>>                                              (?g . "now")
>>                                              (?f . (read-file-name "File: 
>> "))))
>
> ELisp forms under a quote make me cringe.
>
> Code should be quoted with `lambda` (which you run with `funcall` or
> `apply`), not with `quote` (for which you need to use `eval`).
>
> So we should aim for a source code of the form:
>
>     (format-spec "Go to line %n in file %f %g"
>                  `((?n . ,(λ () (read-number "Number: ")))
>                    (?g . "now")
>                    (?f . ,(λ () (read-file-name "File: ")))))

Is there no worthwhile information to pass the lambda function?

(I like the λ notation by the way, would be nice to have a (defalias 'λ
#'lambda) in subr.el).

>
> -- Stefan



reply via email to

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