Added EmacsConfigurationAndHelp directory
[temp.git] / .emacs.d / org-man.el~
blobfb970d9e7b27398774cdf3599d7b08dd479777da
1 ;;; org-man.el - Support for links to manpages in Org
2      
3      (require 'org)
4      
5      (org-add-link-type "man" 'org-man-open)
6      (add-hook 'org-store-link-functions 'org-man-store-link)
7      
8      (defcustom org-man-command 'man
9        "The Emacs command to be used to display a man page."
10        :group 'org-link
11        :type '(choice (const man) (const woman)))
12      
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))
17      
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)))
25            (org-store-link-props
26             :type "man"
27             :link link
28             :description description))))
29      
30      (defun org-man-get-page-name ()
31        "Extract the page name from the buffer name."
32        ;; This works for both `Man-mode' and `woman-mode'.
33        (if (string-match " \\(\\S-+\\)\\*" (buffer-name))
34            (match-string 1 (buffer-name))
35          (error "Cannot create link to this man page")))
36      
37      (provide 'org-man)
38      
39      ;;; org-man.el ends here