From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: HELP: One Bindkey for Two Different Commands Date: Wed, 21 Nov 2007 08:46:08 +0100 Organization: Organization?!? Message-ID: <85y7cshwhr.fsf@lola.goethe.zz> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1195634445 16919 80.91.229.12 (21 Nov 2007 08:40:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Nov 2007 08:40:45 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Nov 21 09:40:52 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Iul8d-0006QB-Md for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Nov 2007 09:40:51 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iul8P-0004R1-P6 for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Nov 2007 03:40:37 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsinpeer00.lnd.ops.eu.uu.net!emea.uu.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux) Cancel-Lock: sha1:wTSpFfrCZc//UP8mUUOuGi87yBg= Original-Lines: 32 Original-NNTP-Posting-Date: 21 Nov 2007 08:46:02 CET Original-NNTP-Posting-Host: ec385c57.newsspool2.arcor-online.net Original-X-Trace: DXC=dJd<0>67WFZE47KDAk81NWA9EHlD; 3YcR4Fo<]lROoRQ4nDHegD_]RUo[l8G9]@VS^CV`H8_`hhQT^9QSCVg3dOVOIC5DBZVJ9[:g][?EjI45VF:mKe7b8Qf\ Original-X-Complaints-To: usenet-abuse@arcor.de Original-Xref: shelby.stanford.edu gnu.emacs.help:153955 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:49387 Archived-At: "Drew Adams" 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