]> code.delx.au - gnu-emacs/commitdiff
Warn that interactive should get point and mark only after minibuffer input.
authorRichard M. Stallman <rms@gnu.org>
Sat, 25 Feb 1995 20:57:45 +0000 (20:57 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sat, 25 Feb 1995 20:57:45 +0000 (20:57 +0000)
lispref/commands.texi

index fc9ed30aee390e6a72790f0a2392a6d94bebb8b8..e95b5599ad393dd41ddba4d0f453abf0082aed6e 100644 (file)
@@ -178,6 +178,31 @@ 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