1 ;;; org-man.el - Support for links to manpages in Org
5 (org-add-link-type "man" 'org-man-open
)
6 (add-hook 'org-store-link-functions
'org-man-store-link
)
8 (defcustom org-man-command
'man
9 "The Emacs command to be used to display a man page."
11 :type
'(choice (const man
) (const woman
)))
13 (defun org-man-open (path)
14 "Visit the manpage on PATH.
15 PATH should be a topic that can be thrown at the man command."
16 (funcall org-man-command path
))
18 (defun org-man-store-link ()
19 "Store a link to a manpage."
20 (when (memq major-mode
'(Man-mode woman-mode
))
21 ;; This is a man page, we do make this link
22 (let* ((page (org-man-get-page-name))
23 (link (concat "man:" page
))
24 (description (format "Manpage for %s" page
)))
28 :description description
))))
29 (defun org-man-get-page-name ()
30 "Extract the page name from the buffer name."
31 ;; This works for both `Man-mode' and `woman-mode'.
32 (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
33 (match-string 1 (buffer-name))
34 (error "Cannot create link to this man page")))
38 ;;; org-man.el ends here