Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2017-06-09 09:45:08 +02:00
commit 54344574c6
2 changed files with 22 additions and 9 deletions

View File

@ -712,14 +712,18 @@ Return the number of footnotes removed."
(let ((def-re (format "^\\[fn:%s\\]" (regexp-quote label))) (let ((def-re (format "^\\[fn:%s\\]" (regexp-quote label)))
(ndef 0)) (ndef 0))
(while (re-search-forward def-re nil t) (while (re-search-forward def-re nil t)
(let ((full-def (org-footnote-at-definition-p))) (pcase (org-footnote-at-definition-p)
(when full-def (`(,_ ,start ,end ,_)
;; Remove the footnote, and all blank lines before it. ;; Remove the footnote, and all blank lines before it.
(goto-char (nth 1 full-def)) (delete-region (progn
(skip-chars-backward " \r\t\n") (goto-char start)
(unless (bolp) (forward-line)) (skip-chars-backward " \r\t\n")
(delete-region (point) (nth 2 full-def)) (if (bobp) (point) (line-beginning-position 2)))
(cl-incf ndef)))) (progn
(goto-char end)
(skip-chars-backward " \r\t\n")
(if (bobp) (point) (line-beginning-position 2))))
(cl-incf ndef))))
ndef))) ndef)))
(defun org-footnote-delete (&optional label) (defun org-footnote-delete (&optional label)

View File

@ -166,7 +166,16 @@
(org-test-with-temp-text (org-test-with-temp-text
"Para[fn:1]\n\n[fn:1] para1\n\npara2\n\n\nOutside footnote." "Para[fn:1]\n\n[fn:1] para1\n\npara2\n\n\nOutside footnote."
(org-footnote-delete "1") (org-footnote-delete "1")
(org-trim (buffer-string))))))) (org-trim (buffer-string))))))
;; Remove blank lines above the footnote but preserve those after
;; it.
(should
(equal "Text\n\n\nOther text."
(let ((org-footnote-section nil))
(org-test-with-temp-text
"Text[fn:1]\n\n[fn:1] Definition.\n\n\nOther text."
(org-footnote-delete "1")
(buffer-string))))))
(ert-deftest test-org-footnote/goto-definition () (ert-deftest test-org-footnote/goto-definition ()
"Test `org-footnote-goto-definition' specifications." "Test `org-footnote-goto-definition' specifications."