summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Guerry <bzg@altern.org>2013-04-26 08:52:43 +0200
committerBastien Guerry <bzg@altern.org>2013-04-26 08:52:43 +0200
commit8d5198d6549b91ac5726b6d8dda652a268064c16 (patch)
treeab6db3d4263427b53a37943b596cc17a950705e9
parentdcb0ac48a8010ac4dba24ac1fed745f1cf2b3133 (diff)
downloadorg-mode-8d5198d6549b91ac5726b6d8dda652a268064c16.tar.gz
org.el (org-insert-heading): Fix case when there the first heading starts at the beginning of the buffer
* org.el (org-insert-heading): Fix case when there the first heading starts at the beginning of the buffer. In this case, `org-backward-heading-same-level' will throw an error in the let form, and the error would fall back on "*" instead of falling back on the correct number of stars to add. Thanks to Jisang Yoo and John Hendy who reported this bug.
-rw-r--r--lisp/org.el8
1 files changed, 7 insertions, 1 deletions
diff --git a/lisp/org.el b/lisp/org.el
index 2576d89..126f9ee 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7523,6 +7523,12 @@ This is important for non-interactive uses of the command."
(or (not (null arg)) org-insert-heading-respect-content))
(level nil)
(on-heading (org-at-heading-p))
+ ;; Get a level to fall back on
+ (fix-level
+ (save-excursion
+ (org-back-to-heading t)
+ (looking-at org-outline-regexp)
+ (make-string (1- (length (match-string 0))) ?*)))
(on-empty-line
(save-excursion (beginning-of-line 1) (looking-at "^\\s-*$")))
(head (save-excursion
@@ -7547,7 +7553,7 @@ This is important for non-interactive uses of the command."
(not (org-previous-line-empty-p t)))
(setq empty-line-p (org-previous-line-empty-p)))
(match-string 0))
- (error "* "))))
+ (error (or fix-level "* ")))))
(blank-a (cdr (assq 'heading org-blank-before-new-entry)))
(blank (if (eq blank-a 'auto) empty-line-p blank-a))
pos hide-previous previous-pos)