From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: rejeep Newsgroups: gmane.emacs.help Subject: Re: How to build a conditional keymap? Date: Sat, 6 Dec 2008 01:16:33 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <64b347a2-156f-4a2c-b05f-9f55c6187b67@k41g2000yqn.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1228556736 21033 80.91.229.12 (6 Dec 2008 09:45:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Dec 2008 09:45:36 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Dec 06 10:46:41 2008 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 1L8tkG-0005j2-4M for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Dec 2008 10:46:40 +0100 Original-Received: from localhost ([127.0.0.1]:51356 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L8tj5-0003BT-HG for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Dec 2008 04:45:27 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!e18g2000yqo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 26 Original-NNTP-Posting-Host: 78.69.174.117 Original-X-Trace: posting.google.com 1228554994 30139 127.0.0.1 (6 Dec 2008 09:16:34 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sat, 6 Dec 2008 09:16:34 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e18g2000yqo.googlegroups.com; posting-host=78.69.174.117; posting-account=H8yP8woAAADJb2XeUDa779ssXpGP88Gj User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.4) Gecko/2008112422 Gentoo Firefox/3.0.4,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:165063 X-Mailman-Approved-At: Sat, 06 Dec 2008 04:43:11 -0500 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:60391 Archived-At: On Dec 6, 7:43=A0am, Ian Eure wrote: > On Dec 5, 2008, at 2:06 AM, rejeep wrote: > > > Hi, > > > I'm trying to create a minor mode. But I get stuck on the mode-map. > > I'm trying to set the keybindings depending on some condition. > > > But this will not work. So basically my question is: How do I best > > build a conditional keymap? > > What's wrong with: > > (define-key mm-minor-mode-map "\C-m" 'mm-b)) > (defun mm-b () > =A0 =A0(interactive) > =A0 =A0(and (< 3 -1) (print "b"))) > > =A0 - Ian That will still bind C-m to mm-b. The condition is to decide whether or not the binding should be set. So if the condition is true I want C- m to be set to mm-b. But if it's false I don't want C-m to change. Sorry if I was unclear about that!