unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: rejeep <johan.rejeep@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: How to build a conditional keymap?
Date: Fri, 5 Dec 2008 02:06:33 -0800 (PST)	[thread overview]
Message-ID: <64b347a2-156f-4a2c-b05f-9f55c6187b67@k41g2000yqn.googlegroups.com> (raw)

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	other threads:[~2008-12-05 10:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-05 10:06 rejeep [this message]
2008-12-06  6:43 ` How to build a conditional keymap? 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=64b347a2-156f-4a2c-b05f-9f55c6187b67@k41g2000yqn.googlegroups.com \
    --to=johan.rejeep@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).