help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to build a conditional keymap?


From: rejeep
Subject: Re: How to build a conditional keymap?
Date: Sat, 6 Dec 2008 07:39:19 -0800 (PST)
User-agent: G2/1.0

On Dec 6, 3:49 pm, Andreas Politz <poli...@fh-trier.de> wrote:
> 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

Ahh, I see. Thanks Andreas!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]