From 20f84420a84997fc0e15df5af2e65b3cfde87ac1 Mon Sep 17 00:00:00 2001 From: Jacob Gerlach Date: Wed, 11 Mar 2015 22:39:11 -0400 Subject: [PATCH] ox.el: Issue error for unresolved fuzzy link * lisp/org-capture.el (org-export-resolve-fuzzy-link): throw error instead of returning nil when link can't be resolved. * testing/lisp/test-ox.el (test-org-export/resolve-fuzzy-link): change last test from should-not to should-error In addition to throwing an error, don't store the failed match in the link cache. TINYCHANGE --- lisp/ox.el | 7 ++++--- testing/lisp/test-ox.el | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index 0c7728f..a28a227 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -4068,7 +4068,7 @@ significant." ;; Last case: link either points to a headline or to nothingness. ;; Try to find the source, with priority given to headlines with ;; the closest common ancestor. If such candidate is found, - ;; return it, otherwise return nil. + ;; return it, otherwise signal an error. (t (let ((find-headline (function @@ -4094,8 +4094,9 @@ significant." (org-element-lineage parent-hl nil t)))) (let ((foundp (funcall find-headline path parent))) (when foundp (throw 'exit foundp)))) - ;; No destination found: return nil. - (and (not match-title-p) (puthash path nil link-cache)))))))) + ;; No destination found: error. + (unless match-title-p + (error (format "Unable to resolve link \"%s\"" raw-path))))))))) (defun org-export-resolve-id-link (link info) "Return headline referenced as LINK destination. diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 1b70a78..7cf1e1d 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -2478,8 +2478,8 @@ Another text. (ref:text) (org-element-type (org-export-resolve-fuzzy-link (org-element-map tree 'link 'identity info t) info))))) - ;; Return nil if no match. - (should-not + ;; Error if no match. + (should-error (org-test-with-parsed-data "[[target]]" (org-export-resolve-fuzzy-link (org-element-map tree 'link 'identity info t) info))) -- 1.9.1