Browse Source

org-footnote: Fix bug related to sorting and folded view

* lisp/org-footnote.el (org-footnote-delete-definitions): Remove blank
  lines before the footnote definition instead of removing those after
  it.
* testing/lisp/test-org-footnote.el: Adapt tests.
Nicolas Goaziou 13 years ago
parent
commit
d6faea24d4
2 changed files with 5 additions and 7 deletions
  1. 5 5
      lisp/org-footnote.el
  2. 0 2
      testing/lisp/test-org-footnote.el

+ 5 - 5
lisp/org-footnote.el

@@ -864,11 +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
-	    ;; 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))
+	    ;; Remove the footnote, and all blank lines before it.
+	    (goto-char (nth 1 full-def))
+	    (skip-chars-backward " \r\t\n")
+	    (unless (bolp) (forward-line))
+	    (delete-region (point) (nth 2 full-def))
 	    (incf ndef))))
       ndef)))
 

+ 0 - 2
testing/lisp/test-org-footnote.el

@@ -109,7 +109,6 @@ Body[1]
 \[4] Inline
 
 \[5] Anonymous
-
 ")))
     ;; 2.2. Put each footnote definition at the end of the section
     ;;      containing its first reference.
@@ -256,7 +255,6 @@ Signature")))))
 \[fn:2] B
 
 \[fn:label] C
-
 ")))))