unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to build a conditional keymap?
@ 2008-12-05 10:06 rejeep
  2008-12-06  6:43 ` Ian Eure
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: rejeep @ 2008-12-05 10:06 UTC (permalink / raw)
  To: help-gnu-emacs

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!


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-12-06 15:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-05 10:06 How to build a conditional keymap? rejeep
2008-12-06  6:43 ` Ian Eure
     [not found] ` <mailman.2040.1228545839.26697.help-gnu-emacs@gnu.org>
2008-12-06  9:16   ` rejeep
2008-12-06 14:49 ` Andreas Politz
2008-12-06 15:39   ` rejeep

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).