summaryrefslogtreecommitdiff
path: root/.config/emacs/modules/mm-documentation.el
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-10-16 22:04:33 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-10-16 22:04:33 +0200
commit0ee7fa9c382ae30295f0b8d88457f7856c7ff800 (patch)
tree6b5a0cf01fa0bfa4d01b0134b268f5d993055c0b /.config/emacs/modules/mm-documentation.el
parentd452ae1347b3711bc0a7ac80cfa2c37d9d63836e (diff)
emacs: Overhaul configuration completely
Diffstat (limited to '.config/emacs/modules/mm-documentation.el')
-rw-r--r--.config/emacs/modules/mm-documentation.el48
1 files changed, 48 insertions, 0 deletions
diff --git a/.config/emacs/modules/mm-documentation.el b/.config/emacs/modules/mm-documentation.el
new file mode 100644
index 0000000..473c766
--- /dev/null
+++ b/.config/emacs/modules/mm-documentation.el
@@ -0,0 +1,48 @@
+;;; mm-documentation.el --- Configuration related to documentation -*- lexical-binding: t; -*-
+
+
+;;; Display Available Keybindings
+
+(use-package which-key
+ :demand t
+ :config
+ (which-key-mode)
+ :custom
+ (which-key-dont-use-unicode nil)
+ (which-key-ellipsis "…")
+ (wihch-key-idle-delay .5))
+
+
+;;; Enhance Describe Commands
+
+(use-package helpful
+ :ensure t
+ :bind (([remap describe-command] . helpful-command)
+ ([remap describe-function] . helpful-callable)
+ ([remap describe-key] . helpful-key)
+ ([remap describe-symbol] . helpful-symbol)
+ ([remap describe-variable] . helpful-variable)
+ (("C-h C-p" . helpful-at-point))))
+
+
+;;; Open Manpage for Symbol
+
+(defun mm-documentation-man-at-point ()
+ "Open a UNIX manual page for the symbol at point."
+ (declare (modes (c-mode c++-mode c-ts-mode c++-ts-mode)))
+ (interactive)
+ (if-let ((symbol
+ (pcase major-mode
+ ((or 'c-mode 'c++-mode)
+ (thing-at-point 'symbol :no-properties))
+ ((or 'c-ts-mode 'c++-ts-mode)
+ (when-let ((node (treesit-thing-at-point "identifier" 'nested)))
+ (treesit-node-text node :no-properties))))))
+ (man symbol)
+ (message "No symbol at point.")))
+
+(dolist (mode '(c-mode c++-mode c-ts-mode c++-ts-mode))
+ (with-eval-after-load mode
+ (require 'man)))
+
+(provide 'mm-documentation)