[gnu.emacs] help with elisp!

sullivan@msor.exeter.ac.uk (Rob Sullivan) (07/12/89)

Can anyone explain to me the use of the statement:

(interactive "P")

or something similar to this within a lisp program as it seems to crop
up in a variety of different guises.

                            Thanks in advance,

                                                     Rob...

kayvan@mrspoc.transact.com (Kayvan Sylvan) (07/13/89)

> Date: 11 Jul 89 17:37:26 GMT
> From: Rob Sullivan
> Organization: MSOR Department, Exeter University, UK
> 
> Can anyone explain to me the use of the statement:
> 
> (interactive "P")

The documentation is quite clear is this case:

Type this in your emacs: C-h f interactive RET

You should get:
----------------------------------------------------------------------
interactive:
Specify a way of parsing arguments for interactive use of a function.
For example, write
  (defun fun (arg) "Doc string" (interactive "p") ...use arg...)
to make arg be the prefix numeric argument when foo is called as a command.
This is actually a declaration rather than a function;
 it tells  call-interactively  how to read arguments
 to pass to the function.
When actually called,  interactive  just returns nil.

The argument of  interactive  is usually a string containing a code letter
 followed by a prompt.  (Some code letters do not use I/O to get
 the argument and do not need prompts.)  To prompt for multiple arguments,
 give a code letter, its prompt, a newline, and another code letter, etc.
If the argument is not a string, it is evaluated to get a list of
 arguments to pass to the function.
Just  (interactive)  means pass no args when calling interactively.

Code letters available are:
a -- Function name: symbol with a function definition.
b -- Name of existing buffer.
B -- Name of buffer, possibly nonexistent.
c -- Character.
C -- Command name: symbol with interactive function definition.
d -- Value of point as number.  Does not do I/O.
D -- Directory name.
f -- Existing file name.
F -- Possibly nonexistent file name.
k -- Key sequence (string).
m -- Value of mark as number.  Does not do I/O.
n -- Number read using minibuffer.
N -- Prefix arg converted to number, or if none, do like code `n'.
p -- Prefix arg converted to number.  Does not do I/O.
P -- Prefix arg in raw form.  Does not do I/O.
r -- Region: point and mark as 2 numeric args, smallest first.  Does no I/O.
s -- Any string.
S -- Any symbol.
v -- Variable name: symbol that is user-variable-p.
x -- Lisp expression read but not evaluated.
X -- Lisp expression read and evaluated.
In addition, if the first character of the string is '*' then an error is
 signaled if the buffer is read-only.
 This happens before reading any arguments.