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

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

How to build a conditional keymap?


From: rejeep
Subject: How to build a conditional keymap?
Date: Fri, 5 Dec 2008 02:06:33 -0800 (PST)
User-agent: G2/1.0

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!


reply via email to

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