[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: An interactive command definiftion
From: |
Oliver Scholz |
Subject: |
Re: An interactive command definiftion |
Date: |
Wed, 11 Aug 2004 14:51:56 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (windows-nt) |
"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é!