This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[RFA 2/5] Bind keys in dwarf-mode-map definition
- From: Tom Tromey <tom at tromey dot com>
- To: binutils at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Fri, 6 Oct 2017 14:41:22 -0600
- Subject: [RFA 2/5] Bind keys in dwarf-mode-map definition
- Authentication-results: sourceware.org; auth=none
- References: <20171006204125.19583-1-tom@tromey.com>
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-06 Tom Tromey <tom@tromey.com>
* dwarf-mode.el (dwarf-mode-map): New defvar.
---
binutils/ChangeLog | 4 ++++
binutils/dwarf-mode.el | 9 +++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 4a470b2..686fdb8 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,5 +1,9 @@
2017-10-06 Tom Tromey <tom@tromey.com>
+ * dwarf-mode.el (dwarf-mode-map): New defvar.
+
+2017-10-06 Tom Tromey <tom@tromey.com>
+
PR binutils/22249:
* dwarf.c (process_debug_info): Skip entire CU if it does not
contain dwarf_start_die.
diff --git a/binutils/dwarf-mode.el b/binutils/dwarf-mode.el
index a944a77..9a31ae2 100644
--- a/binutils/dwarf-mode.el
+++ b/binutils/dwarf-mode.el
@@ -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 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.
--
2.9.5