;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/man-incal.el (require 'close) (require 'man) (require 'scroll) (require 'super) (setq Man-notify-method 'pushy) (setq Man-support-remote-systems t) (defun man-kill-reference () (interactive) (let ((page (car (split-string Man-page-mode-string)))) (when (and (stringp page) (not (string-empty-p page)) ) (let ((page-dc (downcase page))) (kill-new page-dc) (message page-dc) )))) (defun man-find-source () (interactive) (let*((Man-argument-list (split-string Man-arguments)) (section-or-name (car Man-argument-list)) (section (if (numberp section-or-name) section-or-name 1) ) (name (car (last Man-argument-list))) (filename (substring (shell-command-to-string (format "whereis -m %s.%s | cut -d' ' -f 2" name section) ) 0 -1) )) (find-file filename) )) (defun man-set-keys () (let ((kmap Man-mode-map)) (disable-super-global-keys kmap) (set-bury-keys kmap) (set-scroll-keys kmap t) (keymap-set kmap "r" #'Man-update-manpage) (keymap-set kmap ";" #'man-find-source) (keymap-set kmap "s" #'man-kill-reference) (keymap-set kmap "P" #'scroll-up-pane) (keymap-set kmap "N" #'scroll-down-pane) (keymap-set kmap "C-M-n" #'Man-next-manpage) (keymap-set kmap "C-M-p" #'Man-previous-manpage) (keymap-set kmap "b" #'Man-previous-manpage) )) (defun Man-mode-hook-f () (man-set-keys) ) (add-hook 'Man-mode-hook #'Man-mode-hook-f) (provide 'man-incal)