Bind keys in dwarf-mode-map definition
authorTom Tromey <tom@tromey.com>
Fri, 6 Oct 2017 19:18:31 +0000 (13:18 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 10 Oct 2017 19:01:42 +0000 (13:01 -0600)
It's bad Emacs style to define keys from a top-level form.  Instead, one
should define a mode map separately and binding keys in the definition.
This lets users completely override the map by defining it before
loading the mode.

2017-10-10  Tom Tromey  <tom@tromey.com>

* dwarf-mode.el (dwarf-mode-map): New defvar.

binutils/ChangeLog
binutils/dwarf-mode.el

index 9f2e5f0a61c4d2295019874795de49c0acf5fba6..7a7edab7ed0d714065b43475201ca06b64ef3250 100644 (file)
@@ -1,3 +1,7 @@
+2017-10-10  Tom Tromey  <tom@tromey.com>
+
+       * dwarf-mode.el (dwarf-mode-map): New defvar.
+
 2017-10-10  Tom Tromey  <tromey@sourceware.org>
 
        PR 22249
index a944a77c8cc2f9ada101a9e533abf031cdfe48d9..c2c01ee745b520cb04428560709889a5c47068f2 100644 (file)
@@ -141,6 +141,13 @@ A prefix argument means expand all children."
                    (expand-file-name dwarf-file)))
     (set-buffer-modified-p nil)))
 
+(defvar dwarf-mode-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map special-mode-map)
+    (define-key map [(control ?m)] #'dwarf-insert-substructure)
+    map)
+  "Keymap for dwarf-mode buffers.")
+
 (define-derived-mode dwarf-mode special-mode "DWARF"
   "Major mode for browsing DWARF output.
 
@@ -151,8 +158,6 @@ A prefix argument means expand all children."
   (set (make-local-variable 'revert-buffer-function) #'dwarf-do-refresh)
   (jit-lock-register #'dwarf-fontify-region))
 
-(define-key dwarf-mode-map [(control ?m)] #'dwarf-insert-substructure)
-
 ;;;###autoload
 (defun dwarf-browse (file)
   "Invoke `objdump' and put output into a `dwarf-mode' buffer.
This page took 0.026191 seconds and 4 git commands to generate.