From 968313f113254f7faad49b3926f38425a1c68396 Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Mon, 10 Oct 2011 16:25:08 +0530 Subject: [PATCH] org-odt.el: Treat label resolution failures as soft error * contrib/lisp/org-odt.el (org-odt-get-label-definition): If a label cannot be resolved, issue a warning and return nil. (org-odt-fixup-label-references): Nothing to fixup if a referenced label is not seen by the odt exporter. --- contrib/lisp/org-odt.el | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/contrib/lisp/org-odt.el b/contrib/lisp/org-odt.el index fcb1ff672..5c3f7fb34 100644 --- a/contrib/lisp/org-odt.el +++ b/contrib/lisp/org-odt.el @@ -1648,10 +1648,12 @@ See `org-odt-entity-labels-alist' and (let* ((label-props (assoc label org-odt-entity-labels-alist)) (category (nth 1 label-props))) (unless label-props - (error "There is no entity labelled as %s" label)) - (append label-props - (cddr (or (assoc-string category org-odt-label-def-ref-spec t) - (assoc-string "" org-odt-label-def-ref-spec t)))))) + (org-lparse-warn + (format "Unable to resolve reference to label \"%s\"" label))) + (when label-props + (append label-props + (cddr (or (assoc-string category org-odt-label-def-ref-spec t) + (assoc-string "" org-odt-label-def-ref-spec t))))))) (defun org-odt-format-label-definition (label category caption) (assert label) @@ -1680,10 +1682,11 @@ See `org-odt-entity-labels-alist' and (goto-char (point-min)) (while (re-search-forward "" nil t) - (let* ((label (match-string 1))) - (replace-match - (apply 'org-odt-format-label-reference - (org-odt-get-label-definition label)) t t)))) + (let* ((label (match-string 1)) + (label-def (org-odt-get-label-definition label)) + (rpl (and label-def + (apply 'org-odt-format-label-reference label-def)))) + (when rpl (replace-match rpl t t))))) (defun org-odt-format-entity-caption (label caption category) (or (and label (org-odt-format-label-definition label category caption)) -- 2.11.4.GIT