Browse Source

Footnotes: Fix bug with insertion at end of buffer

With the "* Footnotes" heading as last line in the buffer, footnote
insertion did not position new definitions correctly.  This commit
fixes the problem.

Reported by Matt Lundin.
Carsten Dominik 16 years ago
parent
commit
c0100ad2b1
2 changed files with 9 additions and 1 deletions
  1. 7 0
      lisp/ChangeLog
  2. 2 1
      lisp/org-footnote.el

+ 7 - 0
lisp/ChangeLog

@@ -1,3 +1,10 @@
+2009-01-05  Carsten Dominik  <carsten.dominik@gmail.com>
+
+	* org-footnote.el (org-footnote-create-definition)
+	(org-footnote-goto-local-insertion-point): Make footnote insertion
+	work correctly when the "Footnotes" headline is the last line in
+	the buffer.
+
 2009-01-04  Carsten Dominik  <carsten.dominik@gmail.com>
 2009-01-04  Carsten Dominik  <carsten.dominik@gmail.com>
 
 
 	* org-w3m.el (org-w3m): New customization group.
 	* org-w3m.el (org-w3m): New customization group.

+ 2 - 1
lisp/org-footnote.el

@@ -267,7 +267,7 @@ or new, let the user edit the definition of the footnote."
 		    (and (progn (widen) t)
 		    (and (progn (widen) t)
 			 (re-search-forward re nil t)))
 			 (re-search-forward re nil t)))
 	  (goto-char (point-max))
 	  (goto-char (point-max))
-	  (insert "\n\n* " org-footnote-section)))
+	  (insert "\n\n* " org-footnote-section "\n")))
       ;; Now go to the end of this entry and insert there.
       ;; Now go to the end of this entry and insert there.
       (org-footnote-goto-local-insertion-point))
       (org-footnote-goto-local-insertion-point))
      (t
      (t
@@ -452,6 +452,7 @@ ENTRY is (fn-label num-mark definition)."
 (defun org-footnote-goto-local-insertion-point ()
 (defun org-footnote-goto-local-insertion-point ()
   "Find insertion point for footnote, just before next outline heading."
   "Find insertion point for footnote, just before next outline heading."
   (outline-next-heading)
   (outline-next-heading)
+  (or (bolp) (newline))
   (beginning-of-line 0)
   (beginning-of-line 0)
   (while (and (not (bobp)) (= (char-after) ?#))
   (while (and (not (bobp)) (= (char-after) ?#))
     (beginning-of-line 0))
     (beginning-of-line 0))