X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/b3a1cf11635c0d89bb8f8914813ad6071dde99a3..08244b8144daa9b9fdd69fd8d74155b6dd1d9493:/lispref/commands.texi diff --git a/lispref/commands.texi b/lispref/commands.texi index 7a2cdb8edf..0723c368bb 100644 --- a/lispref/commands.texi +++ b/lispref/commands.texi @@ -150,37 +150,6 @@ It may be omitted or @code{nil}; then the command is called with no arguments. This leads quickly to an error if the command requires one or more arguments. -@item -It may be a Lisp expression that is not a string; then it should be a -form that is evaluated to get a list of arguments to pass to the -command. -@cindex argument evaluation form - -If this expression reads keyboard input (this includes using the -minibuffer), keep in mind that the integer value of point or the mark -before reading input may be incorrect after reading input. This is -because the current buffer may be receiving subprocess output; -if subprocess output arrives while the command is waiting for input, -it could relocate point and the mark. - -Here's an example of what @emph{not} to do: - -@smallexample -(interactive - (list (region-beginning) (region-end) - (read-string "Foo: " nil 'my-history))) -@end smallexample - -@noindent -Here's how to avoid the problem, by examining point and the mark only -after reading the keyboard input: - -@smallexample -(interactive - (let ((string (read-string "Foo: " nil 'my-history))) - (list (region-beginning) (region-end) string))) -@end smallexample - @item @cindex argument prompt It may be a string; then its contents should consist of a code character @@ -231,6 +200,39 @@ You can use @samp{*} and @samp{@@} together; the order does not matter. Actual reading of arguments is controlled by the rest of the prompt string (starting with the first character that is not @samp{*} or @samp{@@}). + +@item +It may be a Lisp expression that is not a string; then it should be a +form that is evaluated to get a list of arguments to pass to the +command. Usually this form will call various functions to read input +from the user, most often through the minibuffer (@pxref{Minibuffers}) +or directly from the keyboard (@pxref{Reading Input}). +@cindex argument evaluation form + +Providing point or the mark as an argument value is also common, but +if you do this @emph{and} read input (whether using the minibuffer or +not), be sure to get the integer values of point or the mark after +reading. The current buffer may be receiving subprocess output; if +subprocess output arrives while the command is waiting for input, it +could relocate point and the mark. + +Here's an example of what @emph{not} to do: + +@smallexample +(interactive + (list (region-beginning) (region-end) + (read-string "Foo: " nil 'my-history))) +@end smallexample + +@noindent +Here's how to avoid the problem, by examining point and the mark after +reading the keyboard input: + +@smallexample +(interactive + (let ((string (read-string "Foo: " nil 'my-history))) + (list (region-beginning) (region-end) string))) +@end smallexample @end itemize @cindex examining the @code{interactive} form @@ -360,7 +362,7 @@ An irrelevant argument. This code always supplies @code{nil} as the argument's value. No I/O. @item k -A key sequence (@pxref{Keymap Terminology}). This keeps reading events +A key sequence (@pxref{Key Sequences}). This keeps reading events until a command (or undefined command) is found in the current key maps. The key sequence argument is represented as a string or vector. The cursor does not move into the echo area. Prompt. @@ -2449,7 +2451,7 @@ If a part of @var{body} binds @code{inhibit-quit} to non-@code{nil}, arrival of input during those parts won't cause an abort until the end of that part. -If you want to be able to distingish all possible values computed +If you want to be able to distinguish all possible values computed by @var{body} from both kinds of abort conditions, write the code like this: