From: "Pascal J. Bourguignon" <pjb@informatimago.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Possible to access previous arg in `interactice' call?
Date: Sat, 02 Aug 2014 22:57:04 +0200 [thread overview]
Message-ID: <87iomar4nz.fsf@kuiper.lan.informatimago.com> (raw)
In-Reply-To: mailman.6474.1407001032.1147.help-gnu-emacs@gnu.org
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
prev parent reply other threads:[~2014-08-02 20:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-02 12:15 Possible to access previous arg in `interactice' call? Thorsten Jolitz
2014-08-02 16:29 ` Drew Adams
2014-08-02 17:36 ` Thorsten Jolitz
[not found] ` <mailman.6474.1407001032.1147.help-gnu-emacs@gnu.org>
2014-08-02 20:57 ` Pascal J. Bourguignon [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87iomar4nz.fsf@kuiper.lan.informatimago.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).