From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: rejeep Newsgroups: gmane.emacs.help Subject: How to build a conditional keymap? Date: Fri, 5 Dec 2008 02:06:33 -0800 (PST) Organization: http://groups.google.com Message-ID: <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: 7bit X-Trace: ger.gmane.org 1228486744 23367 80.91.229.12 (5 Dec 2008 14:19:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 5 Dec 2008 14:19:04 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 05 15:20:08 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 1L8bXC-0003eo-Dm for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Dec 2008 15:19:58 +0100 Original-Received: from localhost ([127.0.0.1]:46002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L8bW1-00060j-Op for geh-help-gnu-emacs@m.gmane.org; Fri, 05 Dec 2008 09:18:45 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!k41g2000yqn.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 39 Original-NNTP-Posting-Host: 78.69.174.117 Original-X-Trace: posting.google.com 1228471593 32158 127.0.0.1 (5 Dec 2008 10:06:33 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 5 Dec 2008 10:06:33 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k41g2000yqn.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:165050 X-Mailman-Approved-At: Fri, 05 Dec 2008 09:18:24 -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:60379 Archived-At: 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. I created this minor example to illustrate what I've tried to do so far. (defvar mm-minor-mode-map (make-sparse-keymap) "...") (defun mm-a() (interactive) (print "a")) (defun mm-b() (interactive) (print "b")) (defun mm-keys() (define-key mm-minor-mode-map "\C-n" 'mm-a) (if (< 3 -1) (define-key mm-minor-mode-map "\C-m" 'mm-b)) mm-minor-mode-map) ;;;###autoload (define-minor-mode mm-mode "..." :init-value nil :lighter " ..." :keymap (mm-keys)) ;;;###autoload (provide 'mm) But this will not work. So basically my question is: How do I best build a conditional keymap? Thanks!