Browse Source

org-man.el (org-man-export): New function to export links of type "man"

* org-man.el (org-man-export): New function to export links of
type "man".
Bastien Guerry 5 years ago
parent
commit
255c596f37
1 changed files with 11 additions and 1 deletions
  1. 11 1
      contrib/lisp/org-man.el

+ 11 - 1
contrib/lisp/org-man.el

@@ -27,7 +27,7 @@
 
 (require 'org)
 
-(org-add-link-type "man" 'org-man-open)
+(org-add-link-type "man" 'org-man-open 'org-man-export)
 (add-hook 'org-store-link-functions 'org-man-store-link)
 
 (defcustom org-man-command 'man
@@ -59,6 +59,16 @@ PATH should be a topic that can be thrown at the man command."
       (match-string 1 (buffer-name))
     (error "Cannot create link to this man page")))
 
+(defun org-man-export (link description format)
+  "Export a man page link from Org files."
+  (let ((path (format "http://man.he.net/?topic=%s&section=all" link))
+	(desc (or description link)))
+    (cond
+     ((eq format 'html) (format "<a target=\"_blank\" href=\"%s\">%s</a>" path desc))
+     ((eq format 'latex) (format "\href{%s}{%s}" path desc))
+     ((eq format 'ascii) (format "%s (%s)" desc path))
+     (t path))))
+
 (provide 'org-man)
 
 ;;; org-man.el ends here