Skip to content

Commit

Permalink
org-add-link-type → org-link-set-parameters (Org9)
Browse files Browse the repository at this point in the history
This backward incompatible change is needed in org 9.0+
  • Loading branch information
kaushalmodi committed Aug 10, 2016
1 parent 7a6f15d commit 59bd7e7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions elisp/org-link-ref/org-link-ref.el
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
;; Time-stamp: <2016-07-15 17:42:30 kmodi>
;; Time-stamp: <2016-08-10 16:46:39 kmodi>

;; Implementing Markdown style link IDs in org-mode
;; http://emacs.stackexchange.com/q/594/115

(defun org-link-ref/find-link (link-ref)
(defun org-link-ref-find-link (link-ref)
"Find link corresponding the LINK-REF in the current buffer."
(save-excursion
(goto-char (point-min))
Expand All @@ -15,21 +15,23 @@
(match-string-no-properties 1)
(user-error "Definition for link reference `%s' was not found" link-ref)))))

(defun org-link-ref/follow-link (link-ref)
(defun org-link-ref-follow-link (link-ref)
"Browse the link pointed by LINK-REF."
(browse-url (org-link-ref/find-link link-ref)))
(browse-url (org-link-ref-find-link link-ref)))

(defun org-link-ref/export-link (link-ref desc format)
(defun org-link-ref-export-link (link-ref desc format)
"Create export version of LINK-REF and DESC to FORMAT.
FORMATs understood are `html', `latex' and `ascii'."
(let ((link (org-link-ref/find-link link-ref)))
(let ((link (org-link-ref-find-link link-ref)))
(cond
((eq format 'html) (format "<a href=\"%s\">%s</a>" link desc))
((eq format 'latex) (format "\\href{%s}{%s}" link desc))
((eq format 'ascii) (format "[%s](%s)" desc link))
(t desc))))

(org-add-link-type "link-ref" #'org-link-ref/follow-link #'org-link-ref/export-link)
(org-link-set-parameters "link-ref"
:follow #'org-link-ref-follow-link
:export #'org-link-ref-export-link)


(provide 'org-link-ref)

0 comments on commit 59bd7e7

Please sign in to comment.