unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* interactive codes "p" and "P" - bug or mistake
@ 2011-07-26 16:19 Andreas Röhler
  2011-07-26 16:35 ` Drew Adams
  2011-07-26 16:42 ` Teemu Likonen
  0 siblings, 2 replies; 7+ messages in thread
From: Andreas Röhler @ 2011-07-26 16:19 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org List

Hi,

given that function:

(defun foo-bar (foo &optional bar)
   ""
   (interactive "p\nP*")
   (message "foo %s bar %s" foo bar))


as with M- NUMBER M-x foo-bar RET

or C-u M-x foo-bar RET

both interactive codes "p" and "P" send the same/similar:

M- 3 M-x foo-bar RET
--> foo 3 bar 3

C-u M-x foo-bar RET
--> foo 4 bar (4)

Think that's not OK.

My mistake?

Thanks,

Andreas

GNU Emacs 23.3.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars) of 
2011-07-17





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

* RE: interactive codes "p" and "P" - bug or mistake
  2011-07-26 16:19 interactive codes "p" and "P" - bug or mistake Andreas Röhler
@ 2011-07-26 16:35 ` Drew Adams
  2011-07-26 16:42 ` Teemu Likonen
  1 sibling, 0 replies; 7+ messages in thread
From: Drew Adams @ 2011-07-26 16:35 UTC (permalink / raw)
  To: 'Andreas Röhler', help-gnu-emacs

> M- 3 M-x foo-bar RET
> --> foo 3 bar 3
> C-u M-x foo-bar RET
> --> foo 4 bar (4)
> 
> Think that's not OK.  My mistake?

Yes, your mistake, but maybe I misunderstand your question.

`P' uses the raw prefix arg; `p' uses its numeric value.

The raw value can be an integer, nil, the symbol `-', or a list of one integer
element.  The numeric value is always an integer, never a symbol or a list.

See `(elisp) Prefix Command Arguments'.




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

* Re: interactive codes "p" and "P" - bug or mistake
  2011-07-26 16:19 interactive codes "p" and "P" - bug or mistake Andreas Röhler
  2011-07-26 16:35 ` Drew Adams
@ 2011-07-26 16:42 ` Teemu Likonen
  2011-07-26 17:00   ` Andreas Röhler
  1 sibling, 1 reply; 7+ messages in thread
From: Teemu Likonen @ 2011-07-26 16:42 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

* 2011-07-26T18:19:53+02:00 * Andreas Röhler wrote:

> given that function:
>
> (defun foo-bar (foo &optional bar)
>   ""
>   (interactive "p\nP*")
>   (message "foo %s bar %s" foo bar))

I'm not sure what you think is wrong or unexpected there. I suggest
reading info pages

    (info "(elisp) Prefix Command Arguments")
    (info "(elisp) Interactive codes")

Note the difference between "raw" and "numeric" prefix argument.



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

* Re: interactive codes "p" and "P" - bug or mistake
  2011-07-26 16:42 ` Teemu Likonen
@ 2011-07-26 17:00   ` Andreas Röhler
  2011-07-26 17:13     ` Drew Adams
  2011-07-26 17:25     ` Teemu Likonen
  0 siblings, 2 replies; 7+ messages in thread
From: Andreas Röhler @ 2011-07-26 17:00 UTC (permalink / raw)
  To: Teemu Likonen; +Cc: help-gnu-emacs

Am 26.07.2011 18:42, schrieb Teemu Likonen:
> * 2011-07-26T18:19:53+02:00 * Andreas Röhler wrote:
>
>> given that function:
>>
>> (defun foo-bar (foo&optional bar)
>>    ""
>>    (interactive "p\nP*")
>>    (message "foo %s bar %s" foo bar))
>
> I'm not sure what you think is wrong or unexpected there. I suggest
> reading info pages
>
>      (info "(elisp) Prefix Command Arguments")
>      (info "(elisp) Interactive codes")
>
> Note the difference between "raw" and "numeric" prefix argument.
>

Thanks Drews and Teemu,

think I know the docu, maybe I didn't understood it correctly.

IMO the code "p" sends the numerical argument, while "P" the Prefix 
value introduced with C-u

So if I do M-NUMBER, "P" should send nothing.
whilst C-u M-command

both should send their defaults, ie "p" 1 and "P" (4)

?

Cheers,

Andreas



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

* RE: interactive codes "p" and "P" - bug or mistake
  2011-07-26 17:00   ` Andreas Röhler
@ 2011-07-26 17:13     ` Drew Adams
  2011-07-26 17:25     ` Teemu Likonen
  1 sibling, 0 replies; 7+ messages in thread
From: Drew Adams @ 2011-07-26 17:13 UTC (permalink / raw)
  To: 'Andreas Röhler', 'Teemu Likonen'; +Cc: help-gnu-emacs

> IMO the code "p" sends the numerical argument, while "P" the Prefix 
> value introduced with C-u

Correct.  And BTW, the "numerical argument" is nothing more than
`prefix-numeric-value' applied to the raw prefix arg value (the "prefix value
introduced with C-u").

> So if I do M-NUMBER, "P" should send nothing.

No.  There is _always_ a raw prefix-argument value, even if you use none of
`M-NUMBER', `C-NUMBER', `M--', or `C-u'.  If you use none of those then the raw
prefix argument value is nil.

If you use `M-NUMBER' or `C-NUMBER' or `C-u NUMBER' then the raw value is
NUMBER.  This is mentioned in the doc we pointed you to:

 "M-3   M-x display-prefix -| 3  ; (Same as `C-u 3'.)"
 "M-- 7 M-x display-prefix -| -7 ; (Same as `C-u -7'.)"

> whilst C-u M-command
> both should send their defaults, ie "p" 1 and "P" (4)

I don't understand you.  Why `M-command'?
But yes, `C-u' by itself gives 1 for "p" and (4) for "P".




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

* Re: interactive codes "p" and "P" - bug or mistake
  2011-07-26 17:00   ` Andreas Röhler
  2011-07-26 17:13     ` Drew Adams
@ 2011-07-26 17:25     ` Teemu Likonen
  2011-07-26 18:19       ` Andreas Röhler
  1 sibling, 1 reply; 7+ messages in thread
From: Teemu Likonen @ 2011-07-26 17:25 UTC (permalink / raw)
  To: Andreas Röhler; +Cc: help-gnu-emacs

* 2011-07-26T19:00:06+02:00 * Andreas Röhler wrote:

> IMO the code "p" sends the numerical argument, while "P" the Prefix
> value introduced with C-u
>
> So if I do M-NUMBER, "P" should send nothing.
> whilst C-u M-command
>
> both should send their defaults, ie "p" 1 and "P" (4)

No. When you execute a command there is only one prefix argument but
Emacs knows two different _representations_ of it. So, when you type

    C-u M-x command RET

the "command" gets a prefix argument. Its representation in "raw" format
is "(4)", that is, a list with a single item, the integer 4. Its
representation in "numeric" format is the integer 4.



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

* Re: interactive codes "p" and "P" - bug or mistake
  2011-07-26 17:25     ` Teemu Likonen
@ 2011-07-26 18:19       ` Andreas Röhler
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2011-07-26 18:19 UTC (permalink / raw)
  To: Teemu Likonen; +Cc: help-gnu-emacs

Am 26.07.2011 19:25, schrieb Teemu Likonen:
> * 2011-07-26T19:00:06+02:00 * Andreas Röhler wrote:
>
>> IMO the code "p" sends the numerical argument, while "P" the Prefix
>> value introduced with C-u
>>
>> So if I do M-NUMBER, "P" should send nothing.
>> whilst C-u M-command
>>
>> both should send their defaults, ie "p" 1 and "P" (4)
>
> No. When you execute a command there is only one prefix argument but
> Emacs knows two different _representations_ of it. So, when you type
>
>      C-u M-x command RET
>
> the "command" gets a prefix argument. Its representation in "raw" format
> is "(4)", that is, a list with a single item, the integer 4. Its
> representation in "numeric" format is the integer 4.
>

OK, thanks all again.

Thought could have that different.
Will find another solution then.

Andreas




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

end of thread, other threads:[~2011-07-26 18:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-26 16:19 interactive codes "p" and "P" - bug or mistake Andreas Röhler
2011-07-26 16:35 ` Drew Adams
2011-07-26 16:42 ` Teemu Likonen
2011-07-26 17:00   ` Andreas Röhler
2011-07-26 17:13     ` Drew Adams
2011-07-26 17:25     ` Teemu Likonen
2011-07-26 18:19       ` Andreas Röhler

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