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

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

Re: HELP: One Bindkey for Two Different Commands


From: David Kastrup
Subject: Re: HELP: One Bindkey for Two Different Commands
Date: Wed, 21 Nov 2007 08:46:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

"Drew Adams" <drew.adams@oracle.com> writes:

>> Why waste two bindkeys on two similar commands when you can simply
>> write a function to choose the between commands based on context?
>>
>> Unfortunately,  this very simple idea doesn't seem to work for me.
>> Here's what I have in my .emacs so far:
>>
>> (defun ya-ya ()
>>   (if (cdr (window-list))
>>       'other-window
>>     'switch-to-buffer))
>>
>> (global-set-key "\M-o" (ya-ya))
>> Any ideas how this might be accomplished?
>
> 1. To turn a function into a command, add an `interactive' spec.
>
> The functions other-window and switch-to-buffer require arguments.

Your point being?  other-window and switch-to-buffer both have an
interactive spec.

> The second argument to global-set-key is a command, not a list such as
> you have supplied.

He does not supply a list.  He supplies a command.  The problem merely
is that he makes his choice of command at the time of global-set-key,
not at keypress time.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


reply via email to

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