all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
@ 2009-03-19 19:15 ` Alan Mackenzie
  2009-03-19 20:16   ` Leo
  2009-03-19 20:45   ` bug#2723: marked as done (Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.) Emacs bug Tracking System
  0 siblings, 2 replies; 9+ messages in thread
From: Alan Mackenzie @ 2009-03-19 19:15 UTC (permalink / raw)
  To: bug-gnu-emacs

Hi, Emacs!

In the following:

#########################################################################
(defun echo-prefix (arg)
  "Echo the command prefix"
  (interactive "P")
  (message "Command prefix: %s" arg))

(defun echo-region (beg end)
  "Echo the region boundaries"
  (interactive "r")
  (message "Region: (%s %s)" beg end))

(defun echo-region-prefix (beg end arg)
  "Echo the region and prefix parameters."
  (interactive "rP")
  (message "region: (%s %s); prefix: %s" beg end arg))
#########################################################################

, echo-prefix and echo-region work as expected.  echo-region-prefix
throws this error:

    Wrong number of arguments: (lambda (beg end arg) "Echo the region and
    prefix parameters." (interactive "rP") (message "region: (%s %s);
    prefix: %s" beg end arg)), 2

It seems that `(interactive "rP")' is only supplying the defun with two
parameters.

-- 
Alan Mackenzie (Nuremberg, Germany).







^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
  2009-03-19 19:15 ` bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive Alan Mackenzie
@ 2009-03-19 20:16   ` Leo
  2009-03-19 20:45   ` bug#2723: marked as done (Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.) Emacs bug Tracking System
  1 sibling, 0 replies; 9+ messages in thread
From: Leo @ 2009-03-19 20:16 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 2723

On 2009-03-19 19:15 +0000, Alan Mackenzie wrote:
> (defun echo-region-prefix (beg end arg)
>   "Echo the region and prefix parameters."
>   (interactive "rP")
>   (message "region: (%s %s); prefix: %s" beg end arg))

They have to be separated by "\n" as follows.

(defun echo-region-prefix (beg end arg)
  "Echo the region and prefix parameters."
  (interactive "r\nP")
  (message "region: (%s %s); prefix: %s" beg end arg))

I tested it in GNU Emacs 23.0.60.1 (i686-pc-linux-gnu, GTK+ Version
2.12.0) of 2008-12-15.

-- 
.:  Leo  :.  [ sdl.web AT gmail.com ]  .: I use Emacs :.

               www.git-scm.com
    git - the one true version control system






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2723: marked as done (Emacs 23: `interactive': prefix  argument "P" and region "r" are mutually exclusive.)
  2009-03-19 19:15 ` bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive Alan Mackenzie
  2009-03-19 20:16   ` Leo
@ 2009-03-19 20:45   ` Emacs bug Tracking System
  1 sibling, 0 replies; 9+ messages in thread
From: Emacs bug Tracking System @ 2009-03-19 20:45 UTC (permalink / raw)
  To: Stefan Monnier

[-- Attachment #1: Type: text/plain, Size: 983 bytes --]


Your message dated Thu, 19 Mar 2009 16:40:11 -0400
with message-id <jwv8wn11c4c.fsf-monnier+emacsbugreports@gnu.org>
and subject line Re: bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
has caused the Emacs bug report #2723,
regarding Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@emacsbugs.donarmstrong.com
immediately.)


-- 
2723: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=2723
Emacs Bug Tracking System
Contact owner@emacsbugs.donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 3130 bytes --]

From: Alan Mackenzie <acm@muc.de>
To: bug-gnu-emacs@gnu.org
Subject: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
Date: Thu, 19 Mar 2009 19:15:24 +0000
Message-ID: <20090319191524.GA2306@muc.de>

Hi, Emacs!

In the following:

#########################################################################
(defun echo-prefix (arg)
  "Echo the command prefix"
  (interactive "P")
  (message "Command prefix: %s" arg))

(defun echo-region (beg end)
  "Echo the region boundaries"
  (interactive "r")
  (message "Region: (%s %s)" beg end))

(defun echo-region-prefix (beg end arg)
  "Echo the region and prefix parameters."
  (interactive "rP")
  (message "region: (%s %s); prefix: %s" beg end arg))
#########################################################################

, echo-prefix and echo-region work as expected.  echo-region-prefix
throws this error:

    Wrong number of arguments: (lambda (beg end arg) "Echo the region and
    prefix parameters." (interactive "rP") (message "region: (%s %s);
    prefix: %s" beg end arg)), 2

It seems that `(interactive "rP")' is only supplying the defun with two
parameters.

-- 
Alan Mackenzie (Nuremberg, Germany).




[-- Attachment #3: Type: message/rfc822, Size: 1930 bytes --]

From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Alan Mackenzie <acm@muc.de>
Cc: 2723-done@emacsbugs.donarmstrong.com
Subject: Re: bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
Date: Thu, 19 Mar 2009 16:40:11 -0400
Message-ID: <jwv8wn11c4c.fsf-monnier+emacsbugreports@gnu.org>

> It seems that `(interactive "rP")' is only supplying the defun with two
> parameters.

Read C-h f interactive RET, and if you read carefully enough you'll see
you need (interactive "r\nP")


        Stefan



^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
       [not found] <jwv8wn11c4c.fsf-monnier+emacsbugreports@gnu.org>
  2009-03-19 19:15 ` bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive Alan Mackenzie
@ 2009-03-19 21:49 ` Alan Mackenzie
  2009-03-20 13:19   ` Stefan Monnier
       [not found] ` <mailman.3605.1237500234.31690.bug-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 9+ messages in thread
From: Alan Mackenzie @ 2009-03-19 21:49 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 2723

Hi, Stefan!

On Thu, Mar 19, 2009 at 04:40:11PM -0400, Stefan Monnier wrote:
> > It seems that `(interactive "rP")' is only supplying the defun with two
> > parameters.

> Read C-h f interactive RET, and if you read carefully enough you'll see
> you need (interactive "r\nP")

No.  I've read closely and it doesn't say this, neither in the doc
string or the Elisp manual.  The pertinent bit of the Elisp manual reads
thusly:

   * It may be a string; then its contents should consist of a code
     character followed by a prompt (which some code characters use and
     some ignore).  The prompt ends either with the end of the string
     or with a newline.  Here is a simple example:

, i.e. the \n terminates the prompt rather than separating it from the
next thing.  This bit of the manual is oblivious to the existence of
descriptors lacking prompts ("p", "P", "r", "d", "i", "m"), and looks
like it could have been written early in Emacs's development, before "p"
and friends existed (if there was such a time).

The only bit of the doc string which is relevant is

    To prompt for multiple arguments, give a code letter, its prompt, a
    newline, and another code letter, etc.

, which implies that the \n is required only where there's prompting
going on, which clearly isn't the case for "P", "r", etc.

Is there any reason why there needs to be a \n separating "P" and "r"?
After all, in a shell, we can write

    tar -xf emacs.tar.gz

, rather than having to do

    tar -x -f emacs.tar.gz

, which is somewhat analagous.  Aternatively, why does the interactive
call function not give an error message?

OK, I'll write the patches for the Elisp manual and `interactive''s doc
string.  Just not tonight.  Should I reopen this bug, submit a new bug,
or just submit the patch?

>         Stefan
> 

-- 
Alan Mackenzie (Nuremberg, Germany).






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
       [not found] ` <mailman.3605.1237500234.31690.bug-gnu-emacs@gnu.org>
@ 2009-03-20  7:59   ` Miles Bader
  0 siblings, 0 replies; 9+ messages in thread
From: Miles Bader @ 2009-03-20  7:59 UTC (permalink / raw)
  To: gnu-emacs-bug

Alan Mackenzie <acm@muc.de> writes:
> Is there any reason why there needs to be a \n separating "P" and "r"?
> After all, in a shell, we can write

An interesting question, but it does keep open the possibility of adding
optional sub-parameters after the operation letter...

-Miles

-- 
Patience, n. A minor form of despair, disguised as a virtue.







^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
  2009-03-19 21:49 ` bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive Alan Mackenzie
@ 2009-03-20 13:19   ` Stefan Monnier
  2009-03-20 14:39     ` Juanma Barranquero
  2009-03-21 15:25     ` Alan Mackenzie
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Monnier @ 2009-03-20 13:19 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 2723

>> > It seems that `(interactive "rP")' is only supplying the defun with two
>> > parameters.
>> Read C-h f interactive RET, and if you read carefully enough you'll see
>> you need (interactive "r\nP")
> No.

I see two bugs:
1 - the doc is unclear about the need for a newline.
2 - arguments without prompts should signal a warning when provided with
    a prompt (this would have helped you find your problem).


        Stefan






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
  2009-03-20 13:19   ` Stefan Monnier
@ 2009-03-20 14:39     ` Juanma Barranquero
  2009-03-21 15:25     ` Alan Mackenzie
  1 sibling, 0 replies; 9+ messages in thread
From: Juanma Barranquero @ 2009-03-20 14:39 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 2723

On Fri, Mar 20, 2009 at 14:19, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> 1 - the doc is unclear about the need for a newline.

As witnessed by

 - org/org-table.el (uses "rP")
 - progmodes/idlwave.el (uses "eP")
 - emulation/viper-util.el (uses "s x")

    Juanma






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
  2009-03-20 13:19   ` Stefan Monnier
  2009-03-20 14:39     ` Juanma Barranquero
@ 2009-03-21 15:25     ` Alan Mackenzie
  2009-03-21 19:07       ` Stefan Monnier
  1 sibling, 1 reply; 9+ messages in thread
From: Alan Mackenzie @ 2009-03-21 15:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Juanma Barranquero, Leo, 2723, Miles Bader

Hi, Stefan et al.,

On Fri, Mar 20, 2009 at 09:19:51AM -0400, Stefan Monnier wrote:
> >> > It seems that `(interactive "rP")' is only supplying the defun with two
> >> > parameters.
> >> Read C-h f interactive RET, and if you read carefully enough you'll see
> >> you need (interactive "r\nP")
> > No.

> I see two bugs:
> 1 - the doc is unclear about the need for a newline.
> 2 - arguments without prompts should signal a warning when provided with
>     a prompt (this would have helped you find your problem).

OK, here's a pair of patches for bug 1.  Any comments before I commit
them?


2009-03-21  Alan Mackenzie  <acm@muc.de>

        * callint.c (Finteractive): Clarify the doc string - even
        promptless elements need \n separators.


*** callint.c.orig	2009-03-08 14:56:05.000000000 +0000
--- callint.c	2009-03-21 14:49:33.360805672 +0000
***************
*** 68,85 ****
  DEFUN ("interactive", Finteractive, Sinteractive, 0, UNEVALLED, 0,
         doc: /* Specify a way of parsing arguments for interactive use of a function.
  For example, write
!   (defun foo (arg) "Doc string" (interactive "p") ...use arg...)
! to make ARG be the prefix argument 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.
  
! The argument of `interactive' is usually a string containing a code letter
!  followed by a prompt.  (Some code letters do not use I/O to get
!  the argument and do not need prompts.)  To prompt for multiple arguments,
!  give a code letter, its prompt, a newline, and another code letter, etc.
!  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.
--- 68,86 ----
  DEFUN ("interactive", Finteractive, Sinteractive, 0, UNEVALLED, 0,
         doc: /* 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.



2009-03-21  Alan Mackenzie  <acm@muc.de>

        * commands.texi (Using Interactive): Clarify string argument to
        `interactive' - even promptless elements need \n separators.


*** commands.texi.orig	2009-02-12 12:10:45.000000000 +0000
--- commands.texi	2009-03-21 14:55:01.964850264 +0000
***************
*** 158,181 ****
  or more arguments.
  
  @item
! It may be a string; then its contents should consist of a code character
! followed by a prompt (which some code characters use and some ignore).
! The prompt ends either with the end of the string or with a newline.
! Here is a simple example:
  
  @smallexample
! (interactive "bFrobnicate buffer: ")
  @end smallexample
  
  @noindent
! The code letter @samp{b} says to read the name of an existing buffer,
! with completion.  The buffer name is the sole argument passed to the
! command.  The rest of the string is a prompt.
! 
! If there is a newline character in the string, it terminates the prompt.
! If the string does not end there, then the rest of the string should
! contain another code character and prompt, specifying another argument.
! You can specify any number of arguments in this way.
  
  @c Emacs 19 feature
  The prompt string can use @samp{%} to include previous argument values
--- 158,179 ----
  or more arguments.
  
  @item
! It may be a string; its contents are a sequence of elements separated
! by newlines, one for each parameter@footnote{Some elements actually
! supply two parameters.}.  Each element consists of a code character
! (@pxref{ Interactive Codes}) optionally followed by a prompt (which
! some code characters use and some ignore).  Here is an example:
  
  @smallexample
! (interactive "P\nbFrobnicate buffer: ")
  @end smallexample
  
  @noindent
! The code letter @samp{P} sets the command's first argument to the raw
! command prefix (@pxref{Prefix Command Arguments}).  @samp{bFrobnicate
! buffer: } prompts the user with @samp{Frobnicate buffer: } to enter
! the name of an existing buffer, which becomes the second and final
! argument.
  
  @c Emacs 19 feature
  The prompt string can use @samp{%} to include previous argument values

> 
>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.
  2009-03-21 15:25     ` Alan Mackenzie
@ 2009-03-21 19:07       ` Stefan Monnier
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2009-03-21 19:07 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Juanma Barranquero, Leo, 2723, Miles Bader

> OK, here's a pair of patches for bug 1.  Any comments before I commit them?

Only one comment from me: thank you,


        Stefan






^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-03-21 19:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <jwv8wn11c4c.fsf-monnier+emacsbugreports@gnu.org>
2009-03-19 19:15 ` bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive Alan Mackenzie
2009-03-19 20:16   ` Leo
2009-03-19 20:45   ` bug#2723: marked as done (Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive.) Emacs bug Tracking System
2009-03-19 21:49 ` bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive Alan Mackenzie
2009-03-20 13:19   ` Stefan Monnier
2009-03-20 14:39     ` Juanma Barranquero
2009-03-21 15:25     ` Alan Mackenzie
2009-03-21 19:07       ` Stefan Monnier
     [not found] ` <mailman.3605.1237500234.31690.bug-gnu-emacs@gnu.org>
2009-03-20  7:59   ` Miles Bader

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.