[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to detect C-u supplied arguments from other prefix arguments
From: |
dieter . wilhelm |
Subject: |
Re: How to detect C-u supplied arguments from other prefix arguments |
Date: |
Wed, 08 Aug 2007 08:32:22 -0000 |
User-agent: |
G2/1.0 |
On 8 août, 07:06, Kevin Rodgers <kevin.d.rodg...@gmail.com> wrote:
> Dieter Wilhelm wrote:
> > I'd like to detect whether prefix arguments of a command are supplied
> > by C-u or otherwise.
> > My idea is to use this-command-keys and compare it to some string,
> > like the following pseudo code:
>
> > (defun bla (arg)
> > (interactive "p")
> > (when (string= "C-u" (substring (this-command-keys) 0 2))
> > (message "hurray")))
>
> > I just don't understand how to compare key sequences. Or maybe
> > there's better way of doing it?
>
> Yuck. If all you're concerned about is whether the prefix arg was
> specified by 1 or more C-u keys (with no minus sign or digits), you
> can use (consp current-prefix-arg).
Unfortunately this doesn't work in all cases: I'd also like to
specify numerical
arguments with C-u (not only powers of 4). For example
C-u 3 M-x some-command
and would like to distinguish it from other means of supplying
numerical
arguments e.g.:
M-3 M-x some-command
> Kevin Rodgers
Thanks
Dieter
Re: How to detect C-u supplied arguments from other prefix arguments, Stefan Monnier, 2007/08/09