Commit c09ac768805a

Vincent Demeester <vincent@sbr.pm>
2019-02-05 18:55:24
setup-org: refactor gh links…
… share gh link parsing Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent d1aefc5
Changed files (1)
lisp/setup-org.el
@@ -194,18 +194,18 @@ like this : [[pt:REGEXP:FOLDER]]"
   (org-link-set-parameters "gh"
                            :follow #'my/follow-gh-link
                            :export (lambda (path desc backend)
-                                     (setq expressions (split-string path "#"))
-                                     (setq project (nth 0 expressions))
-                                     (setq issue (nth 1 expressions))
-                                     (format "https://github.com/%s/issues/%s" project issue))
+                                     (vde/gh-get-url path))
                            :face '(:foreground "DimGrey" :underline t))
   (defun my/follow-gh-link (issue)
     "Browse github issue/pr specified"
-    (setq expressions (split-string issue "#"))
+    (browse-url (vde/gh-get-url issue)))
+
+  (defun vde/gh-get-url (path)
+    "Translate org-mode link `gh:foo/bar#1' to github url."
+    (setq expressions (split-string path "#"))
     (setq project (nth 0 expressions))
     (setq issue (nth 1 expressions))
-    (browse-url
-     (format "https://github.com/%s/issues/%s" project issue)))
+    (format "https://github.com/%s/issues/%s" project issue))
 
   (org-link-set-parameters
    "org"