Skip to content

Commit

Permalink
Define elisp-refs-mode-map using defvar
Browse files Browse the repository at this point in the history
This makes it possible for contributors to do `eval-buffer'
without discarding their personal key bindings every time.
  • Loading branch information
tarsius committed Sep 9, 2018
1 parent 7faa172 commit 3aa49c3
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions elisp-refs.el
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,20 @@ search."
(elisp-refs--read-and-find-symbol buf symbol))
path-prefix))

(defvar elisp-refs-mode-map
(let ((map (make-sparse-keymap)))
;; TODO: it would be nice for TAB to navigate to file buttons too,
;; like *Help* does.
(set-keymap-parent map special-mode-map)
(define-key map (kbd "<tab>") #'elisp-refs-next-match)
(define-key map (kbd "<backtab>") #'elisp-refs-prev-match)
(define-key map (kbd "n") #'elisp-refs-next-match)
(define-key map (kbd "p") #'elisp-refs-prev-match)
(define-key map (kbd "q") #'kill-this-buffer)
(define-key map (kbd "RET") #'elisp-refs-visit-match)
map)
"Keymap for `elisp-refs-mode'.")

(define-derived-mode elisp-refs-mode special-mode "Refs"
"Major mode for refs results buffers.")

Expand Down Expand Up @@ -827,14 +841,5 @@ If DIRECTION is -1, moves backwards instead."
(interactive)
(elisp-refs--move-to-match 1))

;; TODO: it would be nice for TAB to navigate to file buttons too,
;; like *Help* does.
(define-key elisp-refs-mode-map (kbd "<tab>") #'elisp-refs-next-match)
(define-key elisp-refs-mode-map (kbd "<backtab>") #'elisp-refs-prev-match)
(define-key elisp-refs-mode-map (kbd "n") #'elisp-refs-next-match)
(define-key elisp-refs-mode-map (kbd "p") #'elisp-refs-prev-match)
(define-key elisp-refs-mode-map (kbd "q") #'kill-this-buffer)
(define-key elisp-refs-mode-map (kbd "RET") #'elisp-refs-visit-match)

(provide 'elisp-refs)
;;; elisp-refs.el ends here

0 comments on commit 3aa49c3

Please sign in to comment.