[comp.emacs] does concat really return a string

msb@ho5cad.ATT.COM (05/06/88)

I am trying to 'concat' a string to be ised in 'interactive' so that a
default string shows up in the 'interactive' string.  As a test case,
I have the following sections of code.  Doesn't seem that the return
value of 'concat' can be fed to 'interactive'.

What gives?  Is there a good way to print an 'interactive' prompt of
the form:

	"gimme a character [ character-chosen-last-time ]"

Then assume that an empty character assumes the
character-chosen-last-time value?

****************************************************************

;;; This one works
;;; ================================================================
;;; (defun test-case (test-variable)
;;;   "this is a test, only a test.  Do not use it"
;;;   (interactive "*cgimme a character")
;;;   (message "character was %c" test-variable)
;;;   )
;;; 
;;; 
;;; This one chokes with the following error:
;;; 	Wrong type argument: listp, "*cgimme a character"
;;; ================================================================
;;; (defun test-case (test-variable)
;;;   "this is a test, only a test.  Do not use it"
;;;   (interactive (concat "*cgimme " "a " "character"))
;;;   (message "character was %c" test-variable)
;;;   )
;;; 

----------------------------------------------------------------------
<cute quote>            Michael S. Balenger             (201) 949-8789
<cute disclaimer>       AT&T Bell Labs
                        Crawfords Corner Road
ihnp4!ho5cad!msb        Holmdel, NJ   07733

Ram-Ashwin@cs.yale.edu (Ashwin Ram) (05/12/88)

In article <324@ho7cad.ATT.COM>, msb@ho5cad writes:
> I am trying to 'concat' a string to be ised in 'interactive' so that a
> default string shows up in the 'interactive' string.  As a test case,
> I have the following sections of code.  Doesn't seem that the return
> value of 'concat' can be fed to 'interactive'.

No.  If you read the documentation of 'interactive' you'll see why:

        If the argument is not a string, it is evaluated to get a list of
         arguments to pass to the function.

In your second example below:

> ;;;   (interactive "*cgimme a character")
> ;;;   (interactive (concat "*cgimme " "a " "character"))

the concat is supposed to return a list of arguments for the function (as
opposed to a string containing an interactive parsing specification).  You might
try something like:

        (interactive (list (read-char)))

enhanced with a prompt if you like.

-- Ashwin.

ARPA:    Ram-Ashwin@cs.yale.edu
UUCP:    {decvax,ucbvax,harvard,cmcl2,...}!yale!Ram-Ashwin
BITNET:  Ram@yalecs