From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.help Subject: Re: How to build a conditional keymap? Date: Sat, 06 Dec 2008 15:49:17 +0100 Organization: FH-Trier Message-ID: <1228575024.899030@arno.fh-trier.de> 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; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1228578055 11368 80.91.229.12 (6 Dec 2008 15:40:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Dec 2008 15:40:55 +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 16:42:00 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 1L8zI5-0006IH-Gs for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Dec 2008 16:41:57 +0100 Original-Received: from localhost ([127.0.0.1]:47234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L8zGu-00053y-SZ for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Dec 2008 10:40:44 -0500 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!newsfeed00.sul.t-online.de!t-online.de!inka.de!peernews!news.belwue.de!news.uni-kl.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 54 Original-NNTP-Posting-Host: 143-93-54-11.arno.fh-trier.de Original-X-Trace: news.uni-kl.de 1228575068 15970 143.93.54.11 (6 Dec 2008 14:51:08 GMT) Original-X-Complaints-To: usenet@news.uni-kl.de Original-NNTP-Posting-Date: Sat, 6 Dec 2008 14:51:08 +0000 (UTC) User-Agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018) In-Reply-To: <64b347a2-156f-4a2c-b05f-9f55c6187b67@k41g2000yqn.googlegroups.com> Cache-Post-Path: arno.fh-trier.de!unknown@dslb-084-059-194-217.pools.arcor-ip.net X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) Original-Xref: news.stanford.edu gnu.emacs.help:165068 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:60394 Archived-At: 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. > > I created this minor example to illustrate what I've tried to do so > far. > > (defvar mm-minor-mode-map (make-sparse-keymap) > "...") > The keymap should be named MODE-map. > (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! (define-minor-mode mm-mode "..." :init-value nil :lighter " ..." :keymap mm-minor-mode-map (if mm-mode (setq mm-minor-mode-map (mm-keys)))) -ap