From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Oliver Scholz Newsgroups: gmane.emacs.help Subject: Re: An interactive command definiftion Date: Wed, 11 Aug 2004 14:51:56 +0200 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1092229048 928 80.91.224.253 (11 Aug 2004 12:57:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 11 Aug 2004 12:57:28 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 11 14:57:17 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BusfM-0006JZ-00 for ; Wed, 11 Aug 2004 14:57:17 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BusjD-0006zg-G9 for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Aug 2004 09:01:15 -0400 Original-Newsgroups: gnu.emacs.help X-Attribution: os X-Face: "HgH2sgK|bfH$; PiOJI6|qUCf.ve<51_Od(%ynHr?=>znn#~#oS>",F%B8&\vus),2AsPYb -n>PgddtGEn}s7kH?7kH{P_~vu?]OvVN^qD(L)>G^gDCl(U9n{:d>'DkilN!_K"eNzjrtI4Ya6; Td% IZGMbJ{lawG+'J>QXPZD&TwWU@^~A}f^zAb[Ru;CT(UA]c& User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (windows-nt) Cancel-Lock: sha1:xxWkvg9H+4rXJ7pRPuwF/7Wpcxg= Original-NNTP-Posting-Host: 82.83.242.209 Original-X-Trace: 11 Aug 2004 14:51:59 +0200, 82.83.242.209 Original-Lines: 43 Original-X-Complaints-To: abuse@arcor-ip.de Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsmi-us.news.garr.it!NewsITBone-GARR!news.mailgate.org!newsfeed.stueberl.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor-ip.de!news.arcor-ip.de!82.83.242.209 Original-Xref: shelby.stanford.edu gnu.emacs.help:124734 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:20078 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:20078 "Rodolfo Medina" 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é!