summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-02-02 21:02:18 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2012-02-02 21:22:17 +0100
commitd10792510f8eed98bd342b6dbe974bd781bc8ecc (patch)
treee7e55c7a0d9112f15085579686e91f91f587fce1
parentacd743bdc0a42ce2935e67e15a1da49ca5fa4416 (diff)
downloadorg-mode-d10792510f8eed98bd342b6dbe974bd781bc8ecc.tar.gz
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.
-rw-r--r--lisp/org-footnote.el8
1 files changed, 6 insertions, 2 deletions
diff --git a/lisp/org-footnote.el b/lisp/org-footnote.el
index 80d5300..960da7d 100644
--- a/lisp/org-footnote.el
+++ b/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.