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.
This commit is contained in:
Nicolas Goaziou 2012-04-06 19:14:51 +02:00
parent 8cded57cdb
commit 4019559ee2
3 changed files with 10 additions and 9 deletions

View File

@ -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

View File

@ -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)))

View File

@ -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]]"