help-gnu-emacs
[Top][All Lists]
Advanced

[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: Johan Bockgård
Subject: Re: How to detect C-u supplied arguments from other prefix arguments
Date: Wed, 08 Aug 2007 13:55:04 +0200
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1.50 (gnu/linux)

Dieter Wilhelm <dieter@duenenhof-wilhelm.de> writes:

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

You want to check for the character ^U, not the three-character string
`C - u'. Like

    (eq ?\C-u (aref (this-command-keys) 0))

(The whole idea seems a bit ugly though.)

`(substring ... 0 2)' returns a string of length 2, btw.

-- 
Johan Bockgård


reply via email to

[Prev in Thread] Current Thread [Next in Thread]