[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Possible to access previous arg in `interactice' call?
From: |
Pascal J. Bourguignon |
Subject: |
Re: Possible to access previous arg in `interactice' call? |
Date: |
Sat, 02 Aug 2014 22:57:04 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Thorsten Jolitz <tjolitz@gmail.com> writes:
> Drew Adams <drew.adams@oracle.com> writes:
>
>>> (interactive (list (read-number "Num1: ")
>>> (+ (read-number "Num2: ") num1)))
>>>
>>> -> list: Symbol's value as variable is void: num1
>>
>> Bind the value returned by the first `read-number' to a local
>> variable, and use that.
>>
>> (interactive
>> (let ((n1 (read-number "Num1: ")))
>> (list n1 (+ (read-number "Num2: ") n1))))
>
> That works, thanks!
Indeed. Remember that the point of the interactive _declaration_, is to
be able to get the argument _before_ the function is called. Therefore
the parameters are not bound yet!
Declaration means that it's not _executed_ in the body of the command
It declares some behavior that is used before the command is called.
--
__Pascal Bourguignon__ http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk