* (interactive) arguments
@ 2019-12-31 3:50 Jean-Christophe Helary
2020-01-01 15:51 ` Stefan Monnier
0 siblings, 1 reply; 10+ messages in thread
From: Jean-Christophe Helary @ 2019-12-31 3:50 UTC (permalink / raw)
To: help-gnu-emacs
I'm looking for a way to add a default value to interactive by just using the "string" version:
(defun dailyTest (myDate)
(interactive "ntoday: ")
I can do that with the "list" version:
(defun dailyIndex (myDate)
(interactive (list
(read-string "Date: " (format-time-string "%d")))))
Is that possible ?
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (interactive) arguments
2019-12-31 3:50 (interactive) arguments Jean-Christophe Helary
@ 2020-01-01 15:51 ` Stefan Monnier
2020-01-01 16:26 ` Jean-Christophe Helary
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2020-01-01 15:51 UTC (permalink / raw)
To: help-gnu-emacs
> I'm looking for a way to add a default value to interactive by just
> using the "string" version:
[...]
> Is that possible ?
No: you have to use the "list" version (which is really the
"expression" version).
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (interactive) arguments
2020-01-01 15:51 ` Stefan Monnier
@ 2020-01-01 16:26 ` Jean-Christophe Helary
2020-01-02 16:08 ` Jean-Christophe Helary
0 siblings, 1 reply; 10+ messages in thread
From: Jean-Christophe Helary @ 2020-01-01 16:26 UTC (permalink / raw)
To: help-gnu-emacs
> On Jan 2, 2020, at 0:51, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
>> I'm looking for a way to add a default value to interactive by just
>> using the "string" version:
> [...]
>> Is that possible ?
>
> No: you have to use the "list" version (which is really the
> "expression" version).
Thank you Stefan !
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (interactive) arguments
2020-01-01 16:26 ` Jean-Christophe Helary
@ 2020-01-02 16:08 ` Jean-Christophe Helary
2020-01-02 16:30 ` Marcin Borkowski
2020-01-04 16:28 ` Stefan Monnier
0 siblings, 2 replies; 10+ messages in thread
From: Jean-Christophe Helary @ 2020-01-02 16:08 UTC (permalink / raw)
To: help-gnu-emacs
> On Jan 2, 2020, at 1:26, Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org> wrote:
>
>> On Jan 2, 2020, at 0:51, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>
>>> I'm looking for a way to add a default value to interactive by just
>>> using the "string" version:
>> [...]
>>> Is that possible ?
>>
>> No: you have to use the "list" version (which is really the
>> "expression" version).
>
> Thank you Stefan !
Now, when I use the "expression" version, it looks like the arguments are not assigned to variables as they are input, so for ex, I can't use a default value for the input based on the first input...
Is there a way around that ?
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (interactive) arguments
2020-01-02 16:08 ` Jean-Christophe Helary
@ 2020-01-02 16:30 ` Marcin Borkowski
2020-01-02 16:42 ` Jean-Christophe Helary
2020-01-02 16:57 ` Jean-Christophe Helary
2020-01-04 16:28 ` Stefan Monnier
1 sibling, 2 replies; 10+ messages in thread
From: Marcin Borkowski @ 2020-01-02 16:30 UTC (permalink / raw)
To: Jean-Christophe Helary; +Cc: help-gnu-emacs
On 2020-01-02, at 17:08, Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org> wrote:
>> On Jan 2, 2020, at 1:26, Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org> wrote:
>>
>>> On Jan 2, 2020, at 0:51, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>>
>>>> I'm looking for a way to add a default value to interactive by just
>>>> using the "string" version:
>>> [...]
>>>> Is that possible ?
>>>
>>> No: you have to use the "list" version (which is really the
>>> "expression" version).
>>
>> Thank you Stefan !
>
> Now, when I use the "expression" version, it looks like the arguments are not assigned to variables as they are input, so for ex, I can't use a default value for the input based on the first input...
>
> Is there a way around that ?
Does this help?
http://mbork.pl/2015-09-12_A_trick_with_argument_for_interactive_call
Best,
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (interactive) arguments
2020-01-02 16:30 ` Marcin Borkowski
@ 2020-01-02 16:42 ` Jean-Christophe Helary
2020-01-02 16:57 ` Jean-Christophe Helary
1 sibling, 0 replies; 10+ messages in thread
From: Jean-Christophe Helary @ 2020-01-02 16:42 UTC (permalink / raw)
To: help-gnu-emacs
> On Jan 3, 2020, at 1:30, Marcin Borkowski <mbork@mbork.pl> wrote:
>
>
> On 2020-01-02, at 17:08, Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org> wrote:
>
>>> On Jan 2, 2020, at 1:26, Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org> wrote:
>>>
>>>> On Jan 2, 2020, at 0:51, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>>>>
>>>>> I'm looking for a way to add a default value to interactive by just
>>>>> using the "string" version:
>>>> [...]
>>>>> Is that possible ?
>>>>
>>>> No: you have to use the "list" version (which is really the
>>>> "expression" version).
>>>
>>> Thank you Stefan !
>>
>> Now, when I use the "expression" version, it looks like the arguments are not assigned to variables as they are input, so for ex, I can't use a default value for the input based on the first input...
>>
>> Is there a way around that ?
>
> Does this help?
>
> http://mbork.pl/2015-09-12_A_trick_with_argument_for_interactive_call
Yes ! Excellent !
> Well, it is quite similar to the let=/=let* distinction. If only there were something like interactive*…
That's exactly what I was thinking !!! :)
Thank you.
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (interactive) arguments
2020-01-02 16:30 ` Marcin Borkowski
2020-01-02 16:42 ` Jean-Christophe Helary
@ 2020-01-02 16:57 ` Jean-Christophe Helary
2020-01-02 18:11 ` Marcin Borkowski
1 sibling, 1 reply; 10+ messages in thread
From: Jean-Christophe Helary @ 2020-01-02 16:57 UTC (permalink / raw)
To: help-gnu-emacs
> On Jan 3, 2020, at 1:30, Marcin Borkowski <mbork@mbork.pl> wrote:
>
>> Now, when I use the "expression" version, it looks like the arguments are not assigned to variables as they are input, so for ex, I can't use a default value for the input based on the first input...
>>
>> Is there a way around that ?
>
> Does this help?
>
> http://mbork.pl/2015-09-12_A_trick_with_argument_for_interactive_call
→
> The point is that the form right after interactive should return a list of two elements, and that is everything interactive cares for – what the (local) variables inside let* are called is none if its business.
That's really clever ! :)
> Now I’m quite sure that you could cook up a macro interactive*, which would wrap all this in a nice syntax. That, though, I will try some other day.
Have you tried ?
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (interactive) arguments
2020-01-02 16:57 ` Jean-Christophe Helary
@ 2020-01-02 18:11 ` Marcin Borkowski
0 siblings, 0 replies; 10+ messages in thread
From: Marcin Borkowski @ 2020-01-02 18:11 UTC (permalink / raw)
To: Jean-Christophe Helary; +Cc: help-gnu-emacs
On 2020-01-02, at 17:57, Jean-Christophe Helary <jean.christophe.helary@traduction-libre.org> wrote:
>> On Jan 3, 2020, at 1:30, Marcin Borkowski <mbork@mbork.pl> wrote:
>>
>>> Now, when I use the "expression" version, it looks like the arguments are not assigned to variables as they are input, so for ex, I can't use a default value for the input based on the first input...
>>>
>>> Is there a way around that ?
>>
>> Does this help?
>>
>> http://mbork.pl/2015-09-12_A_trick_with_argument_for_interactive_call
>
> →
>> The point is that the form right after interactive should return a list of two elements, and that is everything interactive cares for – what the (local) variables inside let* are called is none if its business.
>
>
> That's really clever ! :)
>
>> Now I’m quite sure that you could cook up a macro interactive*, which would wrap all this in a nice syntax. That, though, I will try some other day.
>
> Have you tried ?
Nope, and now that I know more about Elisp, I'm 99% sure it's
impossible, since `interactive' is not "evaluated" in any sense. But
I'd like to hear from someone more competent.
Best,
--
Marcin Borkowski
http://mbork.pl
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (interactive) arguments
2020-01-02 16:08 ` Jean-Christophe Helary
2020-01-02 16:30 ` Marcin Borkowski
@ 2020-01-04 16:28 ` Stefan Monnier
2020-01-04 17:44 ` Jean-Christophe Helary
1 sibling, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2020-01-04 16:28 UTC (permalink / raw)
To: help-gnu-emacs
> Now, when I use the "expression" version, it looks like the arguments are
> not assigned to variables as they are input, so for ex, I can't use
> a default value for the input based on the first input...
That was my whole point of describing it as "expression" rather than
"list": it is really an arbitrary Elisp *expression* whose evaluation
simply returns the list of arguments to pass to the function.
So it doesn't have to look like
(list ...)
but can be anything else like
(my-function-to-return-the-list-of-args)
or
(let* ((x1 e1) (x2 e2) ...) (append e3 e4))
or
...
-- Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (interactive) arguments
2020-01-04 16:28 ` Stefan Monnier
@ 2020-01-04 17:44 ` Jean-Christophe Helary
0 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe Helary @ 2020-01-04 17:44 UTC (permalink / raw)
To: help-gnu-emacs
> On Jan 5, 2020, at 1:28, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
>> Now, when I use the "expression" version, it looks like the arguments are
>> not assigned to variables as they are input, so for ex, I can't use
>> a default value for the input based on the first input...
>
> That was my whole point of describing it as "expression" rather than
> "list":
:)
> it is really an arbitrary Elisp *expression* whose evaluation
> simply returns the list of arguments to pass to the function.
Indeed, as the doc says. I just got stuck at the "should be a form that is evaluated to get a list of arguments to pass to the command".
>
> So it doesn't have to look like
>
> (list ...)
>
> but can be anything else like
>
> (my-function-to-return-the-list-of-args)
>
> or
> (let* ((x1 e1) (x2 e2) ...) (append e3 e4))
> or
> ...
>
>
> -- Stefan
>
>
>
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-01-04 17:44 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-31 3:50 (interactive) arguments Jean-Christophe Helary
2020-01-01 15:51 ` Stefan Monnier
2020-01-01 16:26 ` Jean-Christophe Helary
2020-01-02 16:08 ` Jean-Christophe Helary
2020-01-02 16:30 ` Marcin Borkowski
2020-01-02 16:42 ` Jean-Christophe Helary
2020-01-02 16:57 ` Jean-Christophe Helary
2020-01-02 18:11 ` Marcin Borkowski
2020-01-04 16:28 ` Stefan Monnier
2020-01-04 17:44 ` Jean-Christophe Helary
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).