From a35c4332f243cc51b2de5adc285d9786e95ef1f6 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Thu, 7 May 2015 22:15:00 +0200 Subject: [PATCH] ox-publish: Allow external references outside of publishing * lisp/ox-publish.el (org-publish-resolve-external-link): Warn instead of throwing an error when a reference to a non-published external file is encountered. --- lisp/ox-publish.el | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/lisp/ox-publish.el b/lisp/ox-publish.el index ff6155958..951f0fe19 100644 --- a/lisp/ox-publish.el +++ b/lisp/ox-publish.el @@ -1144,25 +1144,27 @@ This function allows to resolve external links like: [[file.org::*fuzzy][description]] [[file.org::#custom-id][description]] [[file.org::fuzzy][description]]" - (unless org-publish-cache - (user-error - "Reference \"%s\" in file \"%s\" cannot be resolved without publishing" - search - file)) - (let ((references (org-publish-cache-get-file-property - (expand-file-name file) :references nil t))) - (cond - ((cdr (case (aref search 0) - (?* (assoc (cons 'headline (org-split-string (substring search 1))) - references)) - (?# (assoc (cons 'custom-id (substring search 1)) references)) - (t - (let ((s (org-split-string search))) - (or (assoc (cons 'target s) references) - (assoc (cons 'other s) references) - (assoc (cons 'headline s) references))))))) - (t (message "Unknown cross-reference \"%s\" in file \"%s\"" search file) - "MissingReference")))) + (if (not org-publish-cache) + (progn + (message "Reference \"%s\" in file \"%s\" cannot be resolved without \ +publishing" + search + file) + "MissingReference") + (let ((references (org-publish-cache-get-file-property + (expand-file-name file) :references nil t))) + (cond + ((cdr (case (aref search 0) + (?* (assoc (cons 'headline (org-split-string (substring search 1))) + references)) + (?# (assoc (cons 'custom-id (substring search 1)) references)) + (t + (let ((s (org-split-string search))) + (or (assoc (cons 'target s) references) + (assoc (cons 'other s) references) + (assoc (cons 'headline s) references))))))) + (t (message "Unknown cross-reference \"%s\" in file \"%s\"" search file) + "MissingReference"))))) -- 2.11.4.GIT