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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with keybindings for functions with arguments


From: Joost Kremers
Subject: Re: Problems with keybindings for functions with arguments
Date: 10 Mar 2013 13:26:48 GMT
User-agent: slrn/pre1.0.0-18 (Linux)

Thorsten Jolitz wrote:
> Joost Kremers <joostkremers@yahoo.com> writes:
>> I think it should be possible to incorporate this by using the variabe
>> `current-prefix-arg' (see Info node "(elisp) Prefix Command Arguments").
>> Something like this should work (untested):
>>
>> ,----
>> | (defun navi-show-headers (key prefix)
>> |   (interactive (list (if (featurep 'xemacs)
>> |                          (event-key last-command-event)
>> |                        last-command-event)
>> |                      current-prefix-arg))
>> |   (code...)
>> `----
>
> This is very useful and works in general!
>
> Only in one cornercase it doesn't work: when I bind navi-generic-command
> to "Z", I can use it with or without prefix. But when I bind it to the
> digit "2", it works only without prefix. When I use a prefix, say 'C-u
> 2', or 'C-5 2', the function is never entered. The mini-buffer echoes
> the input and seems to wait - for a key that is not a digit?

Probably, yes... Digits can be (part of) the prefix argument, so I guess
Emacs is waiting for a non-digit key.

I have no idea if there's a workaround for that or not... (Though I
suspect it might require changes at a deeper level than I'd be
comfortable with programming myself. ;-)

> ,--------------------------------------------------------------
>| (defun navi-generic-command (key prefix)
>|   "One size fits all."
>|    (interactive (list last-command-event current-prefix-arg))
>|    (message "%d %s " key (if prefix prefix 999)))

note that something like

,----
| (if prefix prefix 999)
`----

can also be written as

,----
| (or prefix 999)
`----

since or returns the first of its arguments that is non-NIL. :-)

-- 
Joost Kremers                                      joostkremers@yahoo.com
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


reply via email to

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