unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "Edward" <edward.dodge@gmail.com>, <help-gnu-emacs@gnu.org>
Subject: RE: HELP:  One Bindkey for Two Different Commands
Date: Tue, 20 Nov 2007 19:20:38 -0800	[thread overview]
Message-ID: <DNEMKBNJBGPAOPIJOOICCEHBEBAA.drew.adams@oracle.com> (raw)
In-Reply-To: <19f20b9e-58a5-44c5-92bf-39abf6f8db0e@e25g2000prg.googlegroups.com>

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

  reply	other threads:[~2007-11-21  3:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-21  1:41 HELP: One Bindkey for Two Different Commands Edward
2007-11-21  3:20 ` Drew Adams [this message]
2007-11-21 13:03 ` Johan Bockgård
2007-11-30 16:39 ` Stefan Monnier
2007-11-30 16:55   ` Drew Adams
     [not found] <mailman.3868.1195615322.18990.help-gnu-emacs@gnu.org>
2007-11-21  7:46 ` David Kastrup
2007-11-21  9:33   ` Drew Adams
     [not found] <mailman.3878.1195637702.18990.help-gnu-emacs@gnu.org>
2007-11-21 12:46 ` Edward
2007-11-21 15:57   ` Mathias Dahl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DNEMKBNJBGPAOPIJOOICCEHBEBAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    --cc=edward.dodge@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).