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

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

Re: Emacs-Lisp Q: Minor mode keymap


From: Mark Elston
Subject: Re: Emacs-Lisp Q: Minor mode keymap
Date: Fri, 27 Apr 2007 10:49:38 -0700
User-agent: Thunderbird 1.5.0.10 (Windows/20070221)

* Sebastian Meisel wrote (on 4/27/2007 12:25 AM):
Mark Elston schrieb:

What I would like to do is package these functions as a minor
mode with its own keymap and use \C-b in the LaTeX-mode-map
used in AucTeX.  Creating the minor mode map is pretty easy.
I assume that from there I do something like:

  (define-prefix-command my-mode-map)

or something similar.

But from there, I don't see what to do.  Do I have to modify my
.emacs to get the binding correct?  Can't I do it in the minor
mode file?
Put something like that in your mode file:

(defvar YOUR-mode-map
 (let ((map  (make-sparse-keymap)))
   (define-key map "YOURKEYS"  'YOURFUN)
   ...
  map)
 "Keymap for YOUR-mode.")

(define-YOUR-mode
 "MY mode DOESSOMETHING.
Basic Commands
===== ========
\\[YOURFUN]\tDOESSOMETHING.
...
"
:lighter  "THISSHALLFILLMYENTIREMODELINETOSHOWMYMODEISON"
:keymap  YOUR-mode-map)
<----

Replace the uppercase parts ;-)

Let me be a little more clear about what I am trying to accomplish.

I understand how to create a keymap and how to use define-minor-mode
to create a mode that makes use of my keymap.

What I wanted to do was to assign my keymap to the \C-b key in the
LaTeX-mode-map in AucTeX.  Is there a way of doing that in my minor
mode package or do I need to add something to my .emacs to accomplish
this?

This is what I have so far but I haven't found a way of getting
what I am looking for yet.

------------------------------------------------------------------------

(defvar bibs-map nil "\
Keymap containing bindings to the Bibs functions.")

(define-prefix-command 'bibs-map)           ;;; <---Is this necessary?

(define-key bs-map "g" 'bibs-get-ref)
(define-key bs-map "v" 'bibs-find-v-num)
(define-key bs-map "f" 'bibs-fix-quotes)

(define-minor-mode bibs-mode
  ""
  ;; Initial Value
  nil
  ;; The indicator for the mode line
  " Bibs"
  ;; The minor mode bindings
  'bs-map
  (...)           ;;; <------ Is there something I can put here
                  ;;; to associate the (unused) \C-b key in AucTeX
                  ;;; LaTeX-mode-map as a prefix key for bibs-map?
  )


------------------------------------------------------------------------

Alternatively, I could (if necessary) put something in my .emacs that
associates bibs-map with the \C-b in LaTeX-mode-map.  I just don't know
how to do that.

Also, when I toggle off bibs-mode it should remove the keymap from the
\C-b prefix key in LaTeX-mode-map, right?  Again, how do I do that?

Mark


reply via email to

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