From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.help Subject: Re: Rationale behind conversion of a nil prefix arg to numeric 1 Date: Thu, 08 Sep 2016 13:10:56 +0000 Message-ID: References: <87y437c0qg.fsf@bertrandrussell.Speedport_W_723V_1_40_000> <83oa43d9r8.fsf@gnu.org> <06d4a7f1-f116-fb5c-9bd2-c4d1f98934c9@easy-emacs.de> <83k2ercy5u.fsf@gnu.org> <83bn02cs54.fsf@gnu.org> <83ed1411-dbc1-2fe1-5fe9-4fdc7a4d1b21@online.de> <83shteb26t.fsf@gnu.org> <20160906071015.GB15537@tuxteam.de> <87inu98ipz.fsf@bertrandrussell.Speedport_W_723V_1_40_000> <6512cbf9-e702-bc96-7489-54fa23f9bfe8@verizon.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1473349289 22621 195.159.176.226 (8 Sep 2016 15:41:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 8 Sep 2016 15:41:29 +0000 (UTC) To: Charles Millar , help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 08 17:41:25 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bi1S6-00054l-EN for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Sep 2016 17:41:22 +0200 Original-Received: from localhost ([::1]:48785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi1S4-0004MD-C3 for geh-help-gnu-emacs@m.gmane.org; Thu, 08 Sep 2016 11:41:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhz6k-0004oQ-2D for help-gnu-emacs@gnu.org; Thu, 08 Sep 2016 09:11:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhz6h-0001Ld-U0 for help-gnu-emacs@gnu.org; Thu, 08 Sep 2016 09:11:08 -0400 Original-Received: from mail-ua0-x22d.google.com ([2607:f8b0:400c:c08::22d]:33480) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhz6h-0001LX-O3 for help-gnu-emacs@gnu.org; Thu, 08 Sep 2016 09:11:07 -0400 Original-Received: by mail-ua0-x22d.google.com with SMTP id 31so39863049uao.0 for ; Thu, 08 Sep 2016 06:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=dau9GphRBqq9r7UUAmquLMQSXYf4a+TJ8T+uS8/aD0E=; b=SHbrZVLz9P+Hpd/6xpzAbqYOvxHt2O7rZt7Lc2kcdgZVcjMg0EW2YBfZQODCunr2k9 J2WFL9+IFzAjqltE46uD5a9xQLlOnZWCAm8MUWO0q8ztbNHi1rzFe2N3gAfSKYh/T1Sa 0C0tPRnwEiy0Y6r0jTXQD2W5TM7JbFuRl1qBXRwwpOY71oIB0tg7+N3Uz8EM41WlbE6F 43MVeqL8FPpAQS2CyThFU7YKpFBJyFT5SvzydO9I+cQqcozUrai4IPSGT8CSzZQ03viA z9/BAzGSna72QAspxqL4OELtSUoXCMdkC99UoSr+o57UNV5UiZ6kHa6Z9GJmERgoNLUd gq6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=dau9GphRBqq9r7UUAmquLMQSXYf4a+TJ8T+uS8/aD0E=; b=A+BZI1bl1xwOJmuny/p02V813VYVi/VkxvCAkgdUwzLT7MuksgTTad93a6wehJoIip E9ahSEui9yBm/v6wPi05VuSFluSSpHgwTX6IuUf/BuHDtEXliThoe97tHxgGeChbO0Z6 P1hsNeNI/AHtU9IGPymafO5GUSINqk/OX4MsSreJ+TytulB79w98Kc9XFMYRPL0kpBKq 4zsG8ZooqNuF5SJwBodzbsaFyGUpfZp5tF8huddViFdYbdaw0+raVUQnUmrR+1J8kw0D Eiv30up/olNx7FwOFJpsJrDVrTWSluKjT8ZF26HDpsw3rYnY3Qvsa+GbSyQ0IijqQJSJ hp6w== X-Gm-Message-State: AE9vXwMOC4dyOCRUaAL3uAUTVazQD7W2ssxlWFL8crm61v6TJuXt5SBDJGVwr2jEBz/FEsGIxp77nipNvdWOrA== X-Received: by 10.159.33.201 with SMTP id 67mr7706752uac.114.1473340267306; Thu, 08 Sep 2016 06:11:07 -0700 (PDT) In-Reply-To: <6512cbf9-e702-bc96-7489-54fa23f9bfe8@verizon.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400c:c08::22d X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111311 Archived-At: On Wed, Sep 7, 2016 at 10:41 PM Charles Millar wrote: > I have read this thread as well as the other suggested readings. > If the > purpose of either p or P is to pass arguments, I do not understand the > rationale of allowing C-u when using the interactive upper case P. That's useful if the user wants the function to behave different based on if the arg is a list or not. > As > noted above, It returns an integer as the only element in a list, which > if evaluated returns an error. If the arg is a list (C-u), you have to treat it as a list.. e.g. use (car arg). > Is there a use for this? It's up to the user on how they want to treat different arg values. > Such as you may > want an error? Here's a dummy example: (defun foo (arg) (interactive "P") (message (concat "Arg is " (cond ((null arg) "nil") ((listp arg) (format "a list with element %d" (car arg))) (t (format "a number %d" arg)))))) (global-set-key (kbd "C-c '") #'foo)'''' After evaluating the above, do - C-c ' - C-0 C-c ' or M-0 C-c ' - C-1 C-c ' or M-1 C-c ' - .. - C-u C-c ' - C-4 C-c ' or M-4 C-c ' - C-u C-u C-c ' - C-1 C-6 C-c ' or M-1 M-6 C-c ' If the user wishes, they can make the foo function behave differently for each of the above bullets. So it eventually boils down to what the user wants.. do they want the default arg to be nil or 1, do they want to support C-u and C-4 args in different manner, etc. Based on that, they can choose to use the "p" or "P" version of interactive. -- Kaushal Modi