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: Dieter Wilhelm
Subject: Re: How to detect C-u supplied arguments from other prefix arguments
Date: Thu, 09 Aug 2007 08:52:58 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Barry Margolin <barmar@alum.mit.edu> writes:

> In article <1186576048.530383.47680@q75g2000hsh.googlegroups.com>,
>  dieter.wilhelm@googlemail.com wrote:
>
>> On 8 ao?t, 13:55, bojohan+n...@dd.chalmers.se (Johan Bockg?rd) wrote:
>> > Dieter Wilhelm <die...@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))
>> 
>> hurray it works, thanks a lot!
>> >
>> > (The whole idea seems a bit ugly though.)
>> 
>> Why?  In Emacs there are just too little short key combinations free.
>> I'd like to achieve
>> a switch for certain functions depending whether their arguments ARG
>> are supplied by C-u or not.
>> 
>> For example: M-d might kill ARG word with the following boundary/
>> whitespace or without,
>> or C-t might drag a character ARG chars away and in the other case
>> merely transpose neighbouring chars some ARG chars away.
>
> And what if the user decides to bind a different keystroke to 
> universal-argument?

True, from this point of view it's a very bad idea, C-u would be not
customisable any longer.  But I think it's only a marginal problem and
on the other hand I feel the need to expand the Emacs key-binding
space, this is my only idea so far and I will test its feasibility.

Thanks

-- 
    Best wishes

    H. Dieter Wilhelm
    Darmstadt, Germany




reply via email to

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