GNU bug report logs - #17779
24.4.50; (elisp) `Using Interactive'

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Sat, 14 Jun 2014 15:52:01 UTC

Severity: minor

Tags: wontfix

Found in version 24.4.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 17779 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: 17779 <at> debbugs.gnu.org
Subject: Re: bug#17779: 24.4.50; (elisp) `Using Interactive'
Date: Sun, 04 Aug 2019 14:41:55 +0200
Drew Adams <drew.adams <at> oracle.com> writes:

> I wonder about the bullet "It may be a Lisp expression that is not a
> string...".
>
> 1. The text for this does two things, which should perhaps be separated:
> (a) it describes the general nature and use of such an expression, and
> (b) it goes down a rabbit hole to talk about one particular gotcha.
>
> Combining these in the same bullet, which is supposed to present the
> non-string Lisp sexp case, just confuses things - that's my guess.
>
> 2. Wrt that gotcha: Really?  I'm probably missing something here, since
> this text has been in the manual for a long time.  But here's my take on
> this gotcha. What am I missing?

(I've included the .texi below for reference.)

Yes, I think you're right -- the text starting with "Providing point or
the mark" until the end of the example seems like very confusing text to
include in an introduction to `interactive'.  The failure modes (if you
can call it that) are hyper-specific to a very obscure case, and (as
Drew says) what the user should do here depends on what the user wants.

So I think that bit should just be removed from the manual.

Any objections?

----

@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}).

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

----

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 5 years and 352 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.