diff options
| author | Richard M. Stallman | 2006-02-19 23:38:11 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2006-02-19 23:38:11 +0000 |
| commit | df36a07ef048613d662365af32566abf392ffdf7 (patch) | |
| tree | f3c55bf349608708d60b236d74ae17092b23635d | |
| parent | 8b77e9ed72d2b4c7f5e9b1eb775e7db45992ebcd (diff) | |
| download | emacs-df36a07ef048613d662365af32566abf392ffdf7.tar.gz emacs-df36a07ef048613d662365af32566abf392ffdf7.zip | |
(Using Interactive): Put string case before list case.
| -rw-r--r-- | lispref/commands.texi | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/lispref/commands.texi b/lispref/commands.texi index aa05e0a48f2..3b1e9771a1b 100644 --- a/lispref/commands.texi +++ b/lispref/commands.texi | |||
| @@ -150,40 +150,6 @@ It may be omitted or @code{nil}; then the command is called with no | |||
| 150 | arguments. This leads quickly to an error if the command requires one | 150 | arguments. This leads quickly to an error if the command requires one |
| 151 | or more arguments. | 151 | or more arguments. |
| 152 | 152 | ||
| 153 | |||
| 154 | @item | ||
| 155 | It may be a Lisp expression that is not a string; then it should be a | ||
| 156 | form that is evaluated to get a list of arguments to pass to the | ||
| 157 | command. Usually this form will call various functions to read input | ||
| 158 | from the user, most often through the minibuffer (@pxref{Minibuffer}) | ||
| 159 | or directly from the keyboard (@pxref{Reading Input}). | ||
| 160 | @cindex argument evaluation form | ||
| 161 | |||
| 162 | Providing point or the mark as an argument value is also common, but | ||
| 163 | if you do this @emph{and} read input (whether using the minibuffer or | ||
| 164 | not), be sure to get the integer values of point or the mark after | ||
| 165 | reading. The current buffer may be receiving subprocess output; if | ||
| 166 | subprocess output arrives while the command is waiting for input, it | ||
| 167 | could relocate point and the mark. | ||
| 168 | |||
| 169 | Here's an example of what @emph{not} to do: | ||
| 170 | |||
| 171 | @smallexample | ||
| 172 | (interactive | ||
| 173 | (list (region-beginning) (region-end) | ||
| 174 | (read-string "Foo: " nil 'my-history))) | ||
| 175 | @end smallexample | ||
| 176 | |||
| 177 | @noindent | ||
| 178 | Here's how to avoid the problem, by examining point and the mark after | ||
| 179 | reading the keyboard input: | ||
| 180 | |||
| 181 | @smallexample | ||
| 182 | (interactive | ||
| 183 | (let ((string (read-string "Foo: " nil 'my-history))) | ||
| 184 | (list (region-beginning) (region-end) string))) | ||
| 185 | @end smallexample | ||
| 186 | |||
| 187 | @item | 153 | @item |
| 188 | @cindex argument prompt | 154 | @cindex argument prompt |
| 189 | It may be a string; then its contents should consist of a code character | 155 | It may be a string; then its contents should consist of a code character |
| @@ -234,6 +200,39 @@ You can use @samp{*} and @samp{@@} together; the order does not matter. | |||
| 234 | Actual reading of arguments is controlled by the rest of the prompt | 200 | Actual reading of arguments is controlled by the rest of the prompt |
| 235 | string (starting with the first character that is not @samp{*} or | 201 | string (starting with the first character that is not @samp{*} or |
| 236 | @samp{@@}). | 202 | @samp{@@}). |
| 203 | |||
| 204 | @item | ||
| 205 | It may be a Lisp expression that is not a string; then it should be a | ||
| 206 | form that is evaluated to get a list of arguments to pass to the | ||
| 207 | command. Usually this form will call various functions to read input | ||
| 208 | from the user, most often through the minibuffer (@pxref{Minibuffer}) | ||
| 209 | or directly from the keyboard (@pxref{Reading Input}). | ||
| 210 | @cindex argument evaluation form | ||
| 211 | |||
| 212 | Providing point or the mark as an argument value is also common, but | ||
| 213 | if you do this @emph{and} read input (whether using the minibuffer or | ||
| 214 | not), be sure to get the integer values of point or the mark after | ||
| 215 | reading. The current buffer may be receiving subprocess output; if | ||
| 216 | subprocess output arrives while the command is waiting for input, it | ||
| 217 | could relocate point and the mark. | ||
| 218 | |||
| 219 | Here's an example of what @emph{not} to do: | ||
| 220 | |||
| 221 | @smallexample | ||
| 222 | (interactive | ||
| 223 | (list (region-beginning) (region-end) | ||
| 224 | (read-string "Foo: " nil 'my-history))) | ||
| 225 | @end smallexample | ||
| 226 | |||
| 227 | @noindent | ||
| 228 | Here's how to avoid the problem, by examining point and the mark after | ||
| 229 | reading the keyboard input: | ||
| 230 | |||
| 231 | @smallexample | ||
| 232 | (interactive | ||
| 233 | (let ((string (read-string "Foo: " nil 'my-history))) | ||
| 234 | (list (region-beginning) (region-end) string))) | ||
| 235 | @end smallexample | ||
| 237 | @end itemize | 236 | @end itemize |
| 238 | 237 | ||
| 239 | @cindex examining the @code{interactive} form | 238 | @cindex examining the @code{interactive} form |