[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a function more than interactive..
From: |
Tim X |
Subject: |
Re: a function more than interactive.. |
Date: |
Wed, 08 Dec 2010 15:07:57 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
jdx2172 <dj9027@gmail.com> writes:
> [Dont know what to call this functionality in emacs.. hence the
> subject "more than interactive..."]
>
> How do I write a function that when executed prompts the user to enter
> a value at a prompt, asks another value and so on.. until all the
> arguments are provided returns a result.
>
>
>
Just use multiple argument specifiers in your call to interactive
,----[ C-h f interactive RET ]
| interactive is a special form in `C source code'.
|
| (interactive &optional ARGS)
|
| Specify a way of parsing arguments for interactive use of a function.
| For example, write
| (defun foo (arg buf) "Doc string" (interactive "P\nbbuffer: ") .... )
| to make ARG be the raw prefix argument, and set BUF to an existing buffer,
| when `foo' is called as a command.
| The "call" to `interactive' 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.
|
| Usually the argument of `interactive' is a string containing a code letter
| followed optionally by a prompt. (Some code letters do not use I/O to get
| the argument and do not use prompts.) To get several arguments, concatenate
| the individual strings, separating them by newline characters.
| Prompts are passed to format, and may use % escapes to print the
| arguments that have already been read.
| 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 (no input method is used).
| C -- Command name: symbol with interactive function definition.
| d -- Value of point as number. Does not do I/O.
| D -- Directory name.
| e -- Parametrized event (i.e., one that's a list) that invoked this command.
| If used more than once, the Nth `e' returns the Nth parameterized event.
| This skips events that are integers or symbols.
| f -- Existing file name.
| F -- Possibly nonexistent file name.
| G -- Possibly nonexistent file name, defaulting to just directory name.
| i -- Ignored, i.e. always nil. Does not do I/O.
| k -- Key sequence (downcase the last event if needed to get a definition).
| K -- Key sequence to be redefined (do not downcase the last event).
| m -- Value of mark as number. Does not do I/O.
| M -- Any string. Inherits the current input method.
| n -- Number read using minibuffer.
| N -- Numeric prefix arg, 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. Does not inherit the current input method.
| S -- Any symbol.
| U -- Mouse up event discarded by a previous k or K argument.
| v -- Variable name: symbol that is user-variable-p.
| x -- Lisp expression read but not evaluated.
| X -- Lisp expression read and evaluated.
| z -- Coding system.
| Z -- Coding system, nil if no prefix arg.
|
| In addition, if the string begins with `*', an error is signaled if
| the buffer is read-only.
| If the string begins with `@', Emacs searches the key sequence which
| invoked the command for its first mouse click (or any other event
| which specifies a window).
| If the string begins with `^' and `shift-select-mode' is non-nil,
| Emacs first calls the function `handle-shift-selection'.
| You may use `@', `*', and `^' together. They are processed in the
| order that they appear, before reading any arguments.
`----
--
tcross (at) rapttech dot com dot au