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.
This commit is contained in:
Jambunathan K 2011-10-10 16:25:08 +05:30
parent 78a1d2919c
commit 968313f113
1 changed files with 11 additions and 8 deletions

View File

@ -1648,10 +1648,12 @@ See `org-odt-entity-labels-alist' and
(let* ((label-props (assoc label org-odt-entity-labels-alist)) (let* ((label-props (assoc label org-odt-entity-labels-alist))
(category (nth 1 label-props))) (category (nth 1 label-props)))
(unless label-props (unless label-props
(error "There is no entity labelled as %s" label)) (org-lparse-warn
(format "Unable to resolve reference to label \"%s\"" label)))
(when label-props
(append label-props (append label-props
(cddr (or (assoc-string category org-odt-label-def-ref-spec t) (cddr (or (assoc-string category org-odt-label-def-ref-spec t)
(assoc-string "" 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) (defun org-odt-format-label-definition (label category caption)
(assert label) (assert label)
@ -1680,10 +1682,11 @@ See `org-odt-entity-labels-alist' and
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward (while (re-search-forward
"<text:sequence-ref text:ref-name=\"\\([^\"]+\\)\"/>" nil t) "<text:sequence-ref text:ref-name=\"\\([^\"]+\\)\"/>" nil t)
(let* ((label (match-string 1))) (let* ((label (match-string 1))
(replace-match (label-def (org-odt-get-label-definition label))
(apply 'org-odt-format-label-reference (rpl (and label-def
(org-odt-get-label-definition label)) t t)))) (apply 'org-odt-format-label-reference label-def))))
(when rpl (replace-match rpl t t)))))
(defun org-odt-format-entity-caption (label caption category) (defun org-odt-format-entity-caption (label caption category)
(or (and label (org-odt-format-label-definition label category caption)) (or (and label (org-odt-format-label-definition label category caption))