Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!apple!bbn!bbn.com!mesard From: mesard@bbn.com (Wayne Mesard) Newsgroups: comp.emacs Subject: Re: GNU Emacs special form "interactive" Message-ID: <33979@bbn.COM> Date: 30 Dec 88 18:52:38 GMT References: <8812301512.AA10827@decwrl.dec.com> Sender: news@bbn.COM Reply-To: mesard@labs-n.bbn.com (Wayne Mesard) Organization: Bolt Beranek and Newman Inc., Cambridge MA Lines: 37 In article <8812301512.AA10827@decwrl.dec.com> ellis@ultra.dec.com (David Ellis) writes: >What I'd like to do is have a function taking an argument that gets >inserted into a prompt string. >I can do this if I can get the special form "interactive" to take as its >argument a string-valued expression in place of a specific string, for >example > > (interactive (format "s(This is a %s prompt string) : " foo-arg)) > >Unfortunately, GNU Emacs rewards this effort with the error message > > Wrong type argument: listp, "s(This is a Type A prompt string) : " > >saying that "interactive" expects a list (huh?) but has been given a string. As the docs for interactive say, if the argument is not a literal string, it is assumed to be lisp code which, when evaluated, will produce a LIST containing an element to be bound to each of the function parameters. Since interactive acts as a declaration, its args are examined at compile time. (Thus your attempt to use format would not produce the desired result even if you had wrapped a (list ...) call around the format.) The following prompts for a single argument to a function placing a timestamp in the prompt. (interactive (list (read-string (format "The time is %s: " (current-time-string))))) In summary, if the arg to interactive is a literal string, it gets used directly by the code which does the argument binding. Otherwise, it is evaluated and must produce a list, each element of which is bound to one of the functions args. -- void Wayne_Mesard(); Mesard@BBN.COM Bolt Beranek and Newman, Cambridge, MA