branch: master
commit e5fe9e7a0c17ae70899441177865e52279046ca2
Author: viritrilbia <viritrilbia>
Commit: viritrilbia <viritrilbia>
Implemented a 'local to submode class' keymap binding, using a dummy
overlay.
---
ChangeLog | 3 +++
mmm-noweb.el | 33 +++++++++++++++++++++++++++------
2 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 44805a9..cd1fca3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2003-03-03 Michael A. Shulman <[email protected]>
+ * mmm-noweb.el (mmm-noweb-bind-keys): Implemented a "local to
+ submode class" keymap binding.
+
* mmm-vars.el (mmm-set-mode-line): Used correct name for variable.
2003-03-02 Michael A. Shulman <[email protected]>
diff --git a/mmm-noweb.el b/mmm-noweb.el
index 8af8a02..e9be4ca 100644
--- a/mmm-noweb.el
+++ b/mmm-noweb.el
@@ -330,14 +330,35 @@ chunks."
(if list
(goto-char (cadar (nthcdr cnt list))))))))
-(mmm-define-key ?d 'mmm-noweb-narrow-to-doc-chunk)
-(mmm-define-key ?n 'mmm-noweb-goto-next)
-(mmm-define-key ?p 'mmm-noweb-goto-previous)
-(mmm-define-key ?q 'mmm-noweb-fill-chunk)
+;;}}}
+;;{{{ Key mappings
+
+(defvar mmm-noweb-map (make-sparse-keymap))
+(defvar mmm-noweb-prefix-map (make-sparse-keymap))
+(define-key mmm-noweb-map mmm-mode-prefix-key mmm-noweb-prefix-map)
+
+(mmm-define-key ?d 'mmm-noweb-narrow-to-doc-chunk mmm-noweb-prefix-map)
+(mmm-define-key ?n 'mmm-noweb-goto-next mmm-noweb-prefix-map)
+(mmm-define-key ?p 'mmm-noweb-goto-previous mmm-noweb-prefix-map)
+(mmm-define-key ?q 'mmm-noweb-fill-chunk mmm-noweb-prefix-map)
;; Cannot use C-g as goto command, so use C-s.
-(mmm-define-key ?s 'mmm-noweb-goto-chunk)
+(mmm-define-key ?s 'mmm-noweb-goto-chunk mmm-noweb-prefix-map)
+
+(define-key mmm-noweb-prefix-map "\t" 'mmm-noweb-complete-chunk)
+
+;; Don't want to add to either the mmm mode map (used in other mmm
+;; buffers) or the local map (used in other major mode buffers), so we
+;; make a full-buffer spanning overlay and add the map there.
+(defun mmm-noweb-bind-keys ()
+ (save-restriction
+ (widen)
+ (let ((ovl (make-overlay (point-min) (point-max) nil nil t)))
+ ;; 'keymap', not 'local-map'
+ (overlay-put ovl 'keymap mmm-noweb-map))))
+
+(add-hook 'mmm-noweb-class-hook 'mmm-noweb-bind-keys)
-(define-key mmm-mode-prefix-map "\t" 'mmm-noweb-complete-chunk)
+;; TODO: make this overlay go away if mmm is turned off
;;}}}