From: Oliver Scholz <alkibiades@gmx.de>
Subject: Re: An interactive command definiftion
Date: Wed, 11 Aug 2004 14:51:56 +0200 [thread overview]
Message-ID: <upt5x3kib.fsf@ID-87814.user.uni-berlin.de> (raw)
In-Reply-To: mailman.803.1092228211.2011.help-gnu-emacs@gnu.org
"Rodolfo Medina" <romeomedina@libero.it> writes:
[...]
> . Then I want to define a command, let's call it manage-my-weather,
> that prompts me the message:
>
> my-weather is now: sunshine. If it is okay, press enter; if you to change
> it, press c
>
> . Of course, if my-weather were rain, the message should be:
>
> my-weather is now: rain. If it is okay, press enter; if you to change it,
> press c
>
>
> . Then, after pressing c (and then enter, I suppose),
> manage-my-weather should prompt this new message:
>
> enter new value for my-weather
>
> , this way allowing me to change my-weather's value at my pleasure.
> Is it possible to do this, and how?
Instead of a string you may also put a lisp form into the interactive
specification; in that case the form, when evaluated, should return a
list of values for the argument list of the function. This provides
the freedom necessary to achieve what you want:
(defun manage-my-weather (input-char)
(interactive
(let ((prompt (format "my-weather is now: %s. Press `c' to change."
my-weather)))
(list (read-char prompt))))
(when (eq input-char ?c)
(setq my-weather
(intern (read-from-minibuffer "New weather: ")))))
Oliver
--
25 Thermidor an 212 de la Révolution
Liberté, Egalité, Fraternité!
next parent reply other threads:[~2004-08-11 12:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.803.1092228211.2011.help-gnu-emacs@gnu.org>
2004-08-11 12:51 ` Oliver Scholz [this message]
2004-08-11 15:35 ` An interactive command definiftion Rodolfo Medina
2004-08-11 12:40 Rodolfo Medina
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=upt5x3kib.fsf@ID-87814.user.uni-berlin.de \
--to=alkibiades@gmx.de \
/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).