summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-02-24 15:54:01 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-02-24 15:54:01 +0100
commitc76f254e8be9801563599b39c08ced97ae966c0c (patch)
treee8e92474806492c23c7cd414fa2daca0734e5972
parentad7b7efcdc2e0803cbf0257bb2588c8e8e1cac29 (diff)
downloadorg-mode-c76f254e8be9801563599b39c08ced97ae966c0c.tar.gz
ox: Fix custom link handling in anonymous back-end
* lisp/ox.el (org-export-custom-protocol-maybe): Change signature. * contrib/lisp/ox-groff.el (org-groff-link): * lisp/ox-ascii.el (org-ascii-link): * lisp/ox-beamer.el (org-beamer-link): * lisp/ox-html.el (org-html-link): * lisp/ox-latex.el (org-latex-link): * lisp/ox-man.el (org-man-link): * lisp/ox-md.el (org-md-link): * lisp/ox-odt.el (org-odt-link): * lisp/ox-org.el (org-org-link): * lisp/ox-texinfo.el (org-texinfo-link): Apply signature change. * testing/lisp/test-ox.el (test-org-export/custom-protocol-maybe): Update test. Provide explicitly back-end used instead of guessing it from INFO channel as an anonymous back-end could be used, masquerading the real one. Reported-by: Christian Moe <mail@christianmoe.com> <http://permalink.gmane.org/gmane.emacs.orgmode/95402>
-rw-r--r--contrib/lisp/ox-groff.el2
-rw-r--r--lisp/ox-ascii.el2
-rw-r--r--lisp/ox-beamer.el2
-rw-r--r--lisp/ox-html.el2
-rw-r--r--lisp/ox-latex.el2
-rw-r--r--lisp/ox-man.el2
-rw-r--r--lisp/ox-md.el2
-rw-r--r--lisp/ox-odt.el2
-rw-r--r--lisp/ox-org.el2
-rw-r--r--lisp/ox-texinfo.el2
-rw-r--r--lisp/ox.el19
-rw-r--r--testing/lisp/test-ox.el33
12 files changed, 37 insertions, 35 deletions
diff --git a/contrib/lisp/ox-groff.el b/contrib/lisp/ox-groff.el
index bbc1258..d0290dc 100644
--- a/contrib/lisp/ox-groff.el
+++ b/contrib/lisp/ox-groff.el
@@ -1258,7 +1258,7 @@ INFO is a plist holding contextual information. See
(concat "file://" raw-path))
(t raw-path))))
(cond
- ((org-export-custom-protocol-maybe link desc info))
+ ((org-export-custom-protocol-maybe link desc 'groff))
;; Image file.
(imagep (org-groff-link--inline-image link info))
;; import groff files
diff --git a/lisp/ox-ascii.el b/lisp/ox-ascii.el
index ddd7e3e..a8d3eab 100644
--- a/lisp/ox-ascii.el
+++ b/lisp/ox-ascii.el
@@ -1525,7 +1525,7 @@ DESC is the description part of the link, or the empty string.
INFO is a plist holding contextual information."
(let ((type (org-element-property :type link)))
(cond
- ((org-export-custom-protocol-maybe link desc info))
+ ((org-export-custom-protocol-maybe link desc 'ascii))
((string= type "coderef")
(let ((ref (org-element-property :path link)))
(format (org-export-get-coderef-format ref desc)
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el
index fb155ae..e10d36c 100644
--- a/lisp/ox-beamer.el
+++ b/lisp/ox-beamer.el
@@ -691,7 +691,7 @@ used as a communication channel."
(path (org-element-property :path link)))
(cond
;; Link type is handled by a special function.
- ((org-export-custom-protocol-maybe link contents info))
+ ((org-export-custom-protocol-maybe link contents 'beamer))
;; Use \hyperlink command for all internal links.
((equal type "radio")
(let ((destination (org-export-resolve-radio-link link info)))
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 2c191f5..d59eb3a 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2783,7 +2783,7 @@ INFO is a plist holding contextual information. See
(if (org-string-nw-p attr) (concat " " attr) ""))))
(cond
;; Link type is handled by a special function.
- ((org-export-custom-protocol-maybe link desc info))
+ ((org-export-custom-protocol-maybe link desc 'html))
;; Image file.
((and (plist-get info :html-inline-images)
(org-export-inline-image-p
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 0c739ec..6cec8a1 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -2043,7 +2043,7 @@ INFO is a plist holding contextual information. See
(t raw-path))))
(cond
;; Link type is handled by a special function.
- ((org-export-custom-protocol-maybe link desc info))
+ ((org-export-custom-protocol-maybe link desc 'latex))
;; Image file.
(imagep (org-latex--inline-image link info))
;; Radio link: Transcode target's contents and use them as link's
diff --git a/lisp/ox-man.el b/lisp/ox-man.el
index 884554c..864419c 100644
--- a/lisp/ox-man.el
+++ b/lisp/ox-man.el
@@ -659,7 +659,7 @@ INFO is a plist holding contextual information. See
protocol)
(cond
;; Link type is handled by a special function.
- ((org-export-custom-protocol-maybe link desc info))
+ ((org-export-custom-protocol-maybe link desc 'man))
;; External link with a description part.
((and path desc) (format "%s \\fBat\\fP \\fI%s\\fP" path desc))
;; External link without a description part.
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 809ffd6..0c2fd4d 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -314,7 +314,7 @@ a communication channel."
(type (org-element-property :type link)))
(cond
;; Link type is handled by a special function.
- ((org-export-custom-protocol-maybe link contents info))
+ ((org-export-custom-protocol-maybe link contents 'md))
((member type '("custom-id" "id"))
(let ((destination (org-export-resolve-id-link link info)))
(if (stringp destination) ; External file.
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index f960271..aba8232 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -2747,7 +2747,7 @@ INFO is a plist holding contextual information. See
(path (replace-regexp-in-string "&" "&amp;" path)))
(cond
;; Link type is handled by a special function.
- ((org-export-custom-protocol-maybe link desc info))
+ ((org-export-custom-protocol-maybe link desc 'odt))
;; Image file.
((and (not desc) (org-export-inline-image-p
link (plist-get info :odt-inline-image-rules)))
diff --git a/lisp/ox-org.el b/lisp/ox-org.el
index cceccb1..734b8d2 100644
--- a/lisp/ox-org.el
+++ b/lisp/ox-org.el
@@ -146,7 +146,7 @@ CONTENTS is nil. INFO is ignored."
"Transcode LINK object back into Org syntax.
CONTENTS is the description of the link, as a string, or nil.
INFO is a plist containing current export state."
- (or (org-export-custom-protocol-maybe link contents info)
+ (or (org-export-custom-protocol-maybe link contents 'org)
(org-element-link-interpreter link contents)))
(defun org-org-template (contents info)
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index a4f1623..aaad96d 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -919,7 +919,7 @@ INFO is a plist holding contextual information. See
(concat "file:" raw-path))
(t raw-path))))
(cond
- ((org-export-custom-protocol-maybe link desc info))
+ ((org-export-custom-protocol-maybe link desc 'texinfo))
((equal type "radio")
(let ((destination (org-export-resolve-radio-link link info)))
(if (not destination) desc
diff --git a/lisp/ox.el b/lisp/ox.el
index ee7e197..8a7182d 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -3926,19 +3926,18 @@ meant to be translated with `org-export-data' or alike."
(save-match-data
(mapconcat 'identity (org-split-string s "[^a-zA-Z0-9_.-:]+") "-")))
-(defun org-export-custom-protocol-maybe (link desc info)
+(defun org-export-custom-protocol-maybe (link desc backend)
"Try exporting LINK with a dedicated function.
-DESC is its description, as a string, or nil. INFO is the plist
-containing export state. Return output as a string, or nil if no
-protocol handles LINK.
+DESC is its description, as a string, or nil. BACKEND is the
+back-end used for export, as a symbol.
-A custom protocol is expected to have precedence over regular
-back-end export. The function ignores links with an implicit
-type (e.g., \"custom-id\")."
- (let ((type (org-element-property :type link))
- (backend (let ((b (plist-get info :back-end)))
- (and b (org-export-backend-name b)))))
+Return output as a string, or nil if no protocol handles LINK.
+
+A custom protocol has precedence over regular back-end export.
+The function ignores links with an implicit type (e.g.,
+\"custom-id\")."
+ (let ((type (org-element-property :type link)))
(unless (or (member type '("coderef" "custom-id" "fuzzy" "radio"))
(not backend))
(let ((protocol (nth 2 (assoc type org-link-protocols))))
diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el
index 1ea5120..1b70a78 100644
--- a/testing/lisp/test-ox.el
+++ b/testing/lisp/test-ox.el
@@ -2235,11 +2235,12 @@ Paragraph[fn:1]"
"[[foo:path]]"
(org-export-create-backend
:name 'test
- :transcoders '((section . (lambda (s c i) c))
- (paragraph . (lambda (p c i) c))
- (link . (lambda (l c i)
- (or (org-export-custom-protocol-maybe l c i)
- "failure")))))))))
+ :transcoders
+ '((section . (lambda (s c i) c))
+ (paragraph . (lambda (p c i) c))
+ (link . (lambda (l c i)
+ (or (org-export-custom-protocol-maybe l c 'test)
+ "failure")))))))))
(should-not
(string-match
"success"
@@ -2250,11 +2251,12 @@ Paragraph[fn:1]"
"[[foo:path]]"
(org-export-create-backend
:name 'no-test
- :transcoders '((section . (lambda (s c i) c))
- (paragraph . (lambda (p c i) c))
- (link . (lambda (l c i)
- (or (org-export-custom-protocol-maybe l c i)
- "failure")))))))))
+ :transcoders
+ '((section . (lambda (s c i) c))
+ (paragraph . (lambda (p c i) c))
+ (link . (lambda (l c i)
+ (or (org-export-custom-protocol-maybe l c 'no-test)
+ "failure")))))))))
;; Ignore anonymous back-ends.
(should-not
(string-match
@@ -2265,11 +2267,12 @@ Paragraph[fn:1]"
(org-export-string-as
"[[foo:path]]"
(org-export-create-backend
- :transcoders '((section . (lambda (s c i) c))
- (paragraph . (lambda (p c i) c))
- (link . (lambda (l c i)
- (or (org-export-custom-protocol-maybe l c i)
- "failure"))))))))))
+ :transcoders
+ '((section . (lambda (s c i) c))
+ (paragraph . (lambda (p c i) c))
+ (link . (lambda (l c i)
+ (or (org-export-custom-protocol-maybe l c nil)
+ "failure"))))))))))
(ert-deftest test-org-export/get-coderef-format ()
"Test `org-export-get-coderef-format' specifications."