commit f2c5cf11c2fad2f7eb623de207b89bcc2c5c4121
parent 983ab3b19a1ced5857cfe6de428167d57e3d9487
Author: Lou Woell <lou.woell@posteo.de>
Date:   Mon, 15 Sep 2025 00:21:39 +0200

[haredoc.el] Add default keybindings & document them

Diffstat:
MREADME.md | 23+++++++++++++++++++++++
Mharedoc.el | 26+++++++++++++++++---------
2 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md @@ -58,7 +58,29 @@ $ harehelper list <module> `haredoc.el` provides an emacs interface using harehelper. The main entry points are `haredoc/goto-definition`, `haredoc` and `haredoc/describe-thing-at-point`. +To enable the default keymap in hare-mode, add `haredoc-nav-mode` to your +`hare-mode-hook`. + +```emacs-lisp +(add-hook 'hare-mode-hook #'haredoc-nav-mode) +``` + +- `M-.`: haredoc/goto-defintion +- `C-c C-h`: haredoc +- `C-c C-d`: haredoc/describe-thing-at-point + +Default keybindings in haredoc buffers: + +- `s`: haredoc/goto-src // go to source of definition at point +- `<`: haredoc/back // go back to previous haredoc page visited +- `>`: haredoc/forward // inverse of the former +- `n`: haredoc/next-decl // move cursor down one declaration +- `p`: haredoc/prev-decl // move cursor up one declaration +- `d`: haredoc/narrow // narrow haredoc to documentation of declaration at point +- `u`: haredoc/widen // show documentation for one namespace + #### Installation with [elpaca](https://github.com/progfolio/elpaca) + ```emacs-lisp (use-package haredoc :defer t @@ -67,6 +89,7 @@ are `haredoc/goto-definition`, `haredoc` and `haredoc/describe-thing-at-point`. :repo https://git.repetitions.de/harehelper :pre-build (("make")) :files (:defaults "harehelper")) + :hook (hare-mode . haredoc-nav-mode) :config ;; ... ) diff --git a/haredoc.el b/haredoc.el @@ -248,15 +248,23 @@ the results in a new buffer." (when (derived-mode-p 'haredoc-mode) (haredoc/goto-defintion (haredoc/get-symbol-apt)))) -(defvar haredoc-mode-map - (define-keymap - "s" 'haredoc/goto-src - "b" 'haredoc/back - "f" 'haredoc/forward - "n" 'haredoc/next-decl - "p" 'haredoc/prev-decl - "N" 'haredoc/narrow - "w" 'haredoc/widen)) +(defvar-keymap haredoc-map + "C-c C-h" 'haredoc + "M-." 'haredoc/goto-defintion + "C-c C-d" 'haredoc/describe-thing-at-point) + +(define-minor-mode haredoc-nav-mode + "Enable navigation of hare symbols and easy access to haredoc pages." + :keymap haredoc-map) + +(defvar-keymap haredoc-mode-map + "s" 'haredoc/goto-src + "<" 'haredoc/back + ">" 'haredoc/forward + "n" 'haredoc/next-decl + "p" 'haredoc/prev-decl + "d" 'haredoc/narrow + "w" 'haredoc/widen) (define-derived-mode haredoc-mode help-mode "🐇" (setq header-line-format `((:propertize ,haredoc-current-path face bold))))