From: Charles Millar <millarc@verizon.net>
To: Kaushal Modi <kaushal.modi@gmail.com>, help-gnu-emacs@gnu.org
Subject: Re: Rationale behind conversion of a nil prefix arg to numeric 1
Date: Thu, 08 Sep 2016 10:42:56 -0400 [thread overview]
Message-ID: <489a1e03-5586-be35-51dc-d5b667aa068e@verizon.net> (raw)
In-Reply-To: <CAFyQvY1H+xdznPf30MP4QJUP4wCXtSXhNMedX=07bHVbrqRZDA@mail.gmail.com>
On 09/08/2016 09:10 AM, Kaushal Modi wrote:
> On Wed, Sep 7, 2016 at 10:41 PM Charles Millar <millarc@verizon.net
> <mailto:millarc@verizon.net>> 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.
> --
Thank you, Kaushal!
I suspect that the following has been said many times on this and other
lists - "An example, as is a picture, is worth a 1000 words."
Charlie Millar
next prev parent reply other threads:[~2016-09-08 14:42 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-04 12:23 Rationale behind conversion of a nil prefix arg to numeric 1 Florian v. Savigny
2016-09-04 14:23 ` Eli Zaretskii
2016-09-04 17:11 ` Andreas Röhler
2016-09-04 18:33 ` Eli Zaretskii
2016-09-05 7:16 ` Andreas Röhler
2016-09-05 14:56 ` Eli Zaretskii
2016-09-05 15:22 ` Kaushal Modi
2016-09-05 16:32 ` Drew Adams
2016-09-05 18:41 ` Andreas Röhler
2016-09-05 19:02 ` Eli Zaretskii
2016-09-06 7:10 ` tomas
2016-09-06 9:45 ` Florian v. Savigny
2016-09-06 10:27 ` tomas
2016-09-06 11:27 ` Andreas Röhler
2016-09-06 13:27 ` Florian v. Savigny
2016-09-06 15:22 ` Drew Adams
2016-09-06 14:20 ` Kaushal Modi
2016-09-06 16:44 ` Andreas Röhler
2016-09-06 16:41 ` Kaushal Modi
2016-09-07 23:11 ` Charles Millar
2016-09-08 13:10 ` Kaushal Modi
2016-09-08 14:42 ` Charles Millar [this message]
2016-09-08 15:40 ` Drew Adams
2016-09-06 7:22 ` Andreas Röhler
2016-09-05 17:04 ` Drew Adams
2016-09-05 21:39 ` Florian v. Savigny
[not found] ` <<877faqvxfp.fsf@bertrandrussell.Speedport_W_723V_1_40_000>
2016-09-05 23:32 ` Drew Adams
2016-09-06 3:45 ` B.V. Raghav
2016-09-04 22:53 ` Florian v. Savigny
[not found] ` <<87d1kjjmys.fsf@bertrandrussell.Speedport_W_723V_1_40_000>
2016-09-05 0:52 ` Drew Adams
2016-09-15 12:47 ` Thien-Thi Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=489a1e03-5586-be35-51dc-d5b667aa068e@verizon.net \
--to=millarc@verizon.net \
--cc=help-gnu-emacs@gnu.org \
--cc=kaushal.modi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).