org-footnote: Fix type error when creating a new footnotemaster
authorNicolas Goaziou <mail@nicolasgoaziou.fr>
Mon, 4 May 2015 07:38:32 +0000 (4 09:38 +0200)
committerNicolas Goaziou <mail@nicolasgoaziou.fr>
Mon, 4 May 2015 07:38:32 +0000 (4 09:38 +0200)
* lisp/org-footnote.el (org-footnote-get-definition): Fix type error
  when creating a new footnote.

When footnote definition is new, contents are nil.

lisp/org-footnote.el

index f4c3f7e..d484de0 100644 (file)
@@ -350,15 +350,18 @@ If no footnote is found, return nil."
                (type (org-element-type datum)))
           (when (memq type '(footnote-definition footnote-reference))
             (throw 'found
-                   (list label
-                         (org-element-property :begin datum)
-                         (org-element-property :end datum)
-                         (replace-regexp-in-string
-                          "[ \t\n]*\\'"
-                          ""
-                          (buffer-substring-no-properties
-                           (org-element-property :contents-begin datum)
-                           (org-element-property :contents-end datum))))))))
+                   (list
+                    label
+                    (org-element-property :begin datum)
+                    (org-element-property :end datum)
+                    (let ((cbeg (org-element-property :contents-begin datum)))
+                      (if (not cbeg) ""
+                        (replace-regexp-in-string
+                         "[ \t\n]*\\'"
+                         ""
+                         (buffer-substring-no-properties
+                          cbeg
+                          (org-element-property :contents-end datum))))))))))
        nil))))
 
 (defun org-footnote-goto-definition (label)