[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: HELP: One Bindkey for Two Different Commands
From: |
Drew Adams |
Subject: |
RE: HELP: One Bindkey for Two Different Commands |
Date: |
Tue, 20 Nov 2007 19:20:38 -0800 |
> 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.
The second argument to global-set-key is a command, not a list such as you
have supplied.
Read the Emacs Lisp manual a bit. Better yet, read the manual Emacs Lisp
Introduction.