From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#2723: Emacs 23: `interactive': prefix argument "P" and region "r" are mutually exclusive. Date: Sat, 21 Mar 2009 15:25:12 +0000 Message-ID: <20090321152511.GA6890@muc.de> References: <20090319191524.GA2306@muc.de> <20090319214904.GA1310@muc.de> Reply-To: Alan Mackenzie , 2723@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1237650246 18056 80.91.229.12 (21 Mar 2009 15:44:06 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 21 Mar 2009 15:44:06 +0000 (UTC) Cc: Juanma Barranquero , Leo , 2723@emacsbugs.donarmstrong.com, Miles Bader To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Mar 21 16:45:22 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Ll3Nw-0002pp-Rr for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Mar 2009 16:45:21 +0100 Original-Received: from localhost ([127.0.0.1]:51778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ll3Ma-00073e-6F for geb-bug-gnu-emacs@m.gmane.org; Sat, 21 Mar 2009 11:43:56 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ll3MW-00072X-EA for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2009 11:43:52 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ll3MR-00071i-2G for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2009 11:43:51 -0400 Original-Received: from [199.232.76.173] (port=56013 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ll3MQ-00071f-Rd for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2009 11:43:46 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:38726) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Ll3MQ-00086O-84 for bug-gnu-emacs@gnu.org; Sat, 21 Mar 2009 11:43:46 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n2LFhiWt008865; Sat, 21 Mar 2009 08:43:44 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n2LFZ2gR006460; Sat, 21 Mar 2009 08:35:02 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Alan Mackenzie Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sat, 21 Mar 2009 15:35:02 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 2723 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 2723-submit@emacsbugs.donarmstrong.com id=B2723.12376491655148 (code B ref 2723); Sat, 21 Mar 2009 15:35:02 +0000 Original-Received: (at 2723) by emacsbugs.donarmstrong.com; 21 Mar 2009 15:26:05 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from mail.muc.de (qmailr@colin.muc.de [193.149.48.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n2LFQ0Q8005142 for <2723@emacsbugs.donarmstrong.com>; Sat, 21 Mar 2009 08:26:02 -0700 Original-Received: (qmail 98532 invoked by uid 3782); 21 Mar 2009 15:25:58 -0000 Original-Received: from acm.muc.de (pD9E53470.dip.t-dialin.net [217.229.52.112]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Sat, 21 Mar 2009 16:25:55 +0100 Original-Received: (qmail 7142 invoked by uid 1000); 21 Mar 2009 15:25:12 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Sat, 21 Mar 2009 11:43:51 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:26533 Archived-At: 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 * 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 * 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).