Browse Source

org-footnote: Don't grab trailing blank lines in a footnote definition

* lisp/org-footnote.el (org-footnote-at-definition-p): Don't grab
  trailing blank lines in a footnote definition.
(org-footnote-delete-definitions): Remove both footnote definition and
trailing blank lines.
* testing/lisp/test-org-export.el (test-org-export/fuzzy-links): Fix
  a docstring.
* contrib/lisp/org-element.el (org-element-footnote-definition-parser):
  Apply change to footnote definitions.
Nicolas Goaziou 13 years ago
parent
commit
4019559ee2
3 changed files with 10 additions and 9 deletions
  1. 3 4
      contrib/lisp/org-element.el
  2. 6 4
      lisp/org-footnote.el
  3. 1 1
      testing/lisp/test-org-export.el

+ 3 - 4
contrib/lisp/org-element.el

@@ -286,10 +286,9 @@ a plist containing `:label', `:begin' `:end', `:contents-begin',
 				  (goto-char (match-end 0))
 				  (org-skip-whitespace)
 				  (point)))
-	   (end (goto-char (nth 2 f-def)))
-	   (contents-end (progn (skip-chars-backward " \r\t\n")
-				(forward-line)
-				(point))))
+	   (contents-end (goto-char (nth 2 f-def)))
+	   (end (progn (org-skip-whitespace)
+		       (if (eobp) (point) (point-at-bol)))))
       `(footnote-definition
 	(:label ,label
 		:begin ,begin

+ 6 - 4
lisp/org-footnote.el

@@ -278,9 +278,7 @@ otherwise."
 			      (concat org-outline-regexp-bol "\\|"
 				      org-footnote-definition-re "\\|"
 				      "^[ \t]*$") bound 'move))
-			   (progn (goto-char (match-beginning 0))
-				  (org-skip-whitespace)
-				  (point-at-bol))
+			   (match-beginning 0)
 			 (point)))))
 	    (list label beg end
 		  (org-trim (buffer-substring-no-properties beg-def end)))))))))
@@ -866,7 +864,11 @@ Return the number of footnotes removed."
       (while (re-search-forward def-re nil t)
 	(let ((full-def (org-footnote-at-definition-p)))
 	  (when full-def
-	    (delete-region (nth 1 full-def) (nth 2 full-def))
+	    ;; Remove the footnote, and all blank lines after it.
+	    (goto-char (nth 2 full-def))
+	    (org-skip-whitespace)
+	    (unless (eobp) (beginning-of-line))
+	    (delete-region (nth 1 full-def) (point))
 	    (incf ndef))))
       ndef)))
 

+ 1 - 1
testing/lisp/test-org-export.el

@@ -403,7 +403,7 @@ body\n")))
 ;;; Links
 
 (ert-deftest test-org-export/fuzzy-links ()
-  "Test fuzz link export specifications."
+  "Test fuzzy link export specifications."
   ;; 1. Links to invisible (keyword) targets should be ignored.
   (org-test-with-temp-text
       "Paragraph.\n#+TARGET: Test\n[[Test]]"