فهرست منبع

org-footnote: Better blank lines control when inserting a footnote

* lisp/org-footnote.el (org-footnote-create-definition): Fix space
  insertion when creating a new footnote. This fixes newline munching
  when `org-footnote-section' is nil and blank lines stacking when it
  isn't nil.

Thanks to Eric Abrahamsen for reporting this.
Nicolas Goaziou 13 سال پیش
والد
کامیت
d10792510f
1فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 6 2
      lisp/org-footnote.el

+ 6 - 2
lisp/org-footnote.el

@@ -547,7 +547,9 @@ or new, let the user edit the definition of the footnote."
 	(unless (bolp) (newline))
 	(set-marker max nil))))
     ;; Insert footnote label.
-    (insert "\n[" label "] ")
+    (when (zerop (org-back-over-empty-lines)) (newline))
+    (insert "[" label "] \n")
+    (backward-char)
     ;; Only notify user about next possible action when in an Org
     ;; buffer, as the bindings may have different meanings otherwise.
     (when (eq major-mode 'org-mode)
@@ -713,10 +715,12 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
 	(if (re-search-forward
 	      (concat "^\\*[ \t]+" (regexp-quote org-footnote-section)
 		      "[ \t]*$") nil t)
-	    (delete-region (match-beginning 0) (org-end-of-subtree t)))
+	    (delete-region (match-beginning 0) (org-end-of-subtree t t)))
 	;; A new footnote section is inserted by default at the end of
 	;; the buffer.
 	(goto-char (point-max))
+	(skip-chars-backward " \r\t\n")
+	(forward-line)
 	(unless (bolp) (newline)))
        ;; No footnote section set: Footnotes will be added before next
        ;; headline.