summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2015-02-03 21:39:30 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2015-02-03 21:39:53 +0100
commit4c00842e8841f01ca31133e6c46ef53c75b47b1b (patch)
tree8963deb7c281d7040578163257456a20a273ca4f
parent43fe141fe39b03a07fd04ce596ca59a8067870c1 (diff)
downloadorg-mode-4c00842e8841f01ca31133e6c46ef53c75b47b1b.tar.gz
Fix `org-toggle-heading'
* lisp/org.el (org-toggle-heading): Avoid adding spurious stars when changing a plain list into a subtree. Reported-by: Rainer Stengele <rainer.stengele@online.de> <http://permalink.gmane.org/gmane.emacs.orgmode/94223>
-rwxr-xr-xlisp/org.el37
1 files changed, 11 insertions, 26 deletions
diff --git a/lisp/org.el b/lisp/org.el
index e59725b..56077d5 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -1,7 +1,7 @@
;;; org.el --- Outline-based notes management and organizer
;; Carstens outline-mode for keeping track of everything.
-;; Copyright (C) 2004-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2004-2015 Free Software Foundation, Inc.
;;
;; Author: Carsten Dominik <carsten at orgmode dot org>
;; Maintainer: Carsten Dominik <carsten at orgmode dot org>
@@ -21223,31 +21223,16 @@ number of stars to add."
;; Case 2. Started at an item: change items into headlines.
;; One star will be added by `org-list-to-subtree'.
((org-at-item-p)
- (let* ((stars (make-string
- ;; subtract the star that will be added again by
- ;; `org-list-to-subtree'
- (if (numberp nstars) (1- nstars)
- (or (org-current-level) 0))
- ?*))
- (add-stars
- (cond (nstars "") ; stars from prefix only
- ((equal stars "") "") ; before first heading
- (org-odd-levels-only "*") ; inside heading, odd
- (t "")))) ; inside heading, oddeven
- (while (< (point) end)
- (when (org-at-item-p)
- ;; Pay attention to cases when region ends before list.
- (let* ((struct (org-list-struct))
- (list-end (min (org-list-get-bottom-point struct) (1+ end))))
- (save-restriction
- (narrow-to-region (point) list-end)
- (insert
- (org-list-to-subtree
- (org-list-parse-list t)
- '(:istart (concat stars add-stars (funcall get-stars depth))
- :icount (concat stars add-stars (funcall get-stars depth)))))))
- (setq toggled t))
- (forward-line))))
+ (while (< (point) end)
+ (when (org-at-item-p)
+ ;; Pay attention to cases when region ends before list.
+ (let* ((struct (org-list-struct))
+ (list-end (min (org-list-get-bottom-point struct) (1+ end))))
+ (save-restriction
+ (narrow-to-region (point) list-end)
+ (insert (org-list-to-subtree (org-list-parse-list t)))))
+ (setq toggled t))
+ (forward-line)))
;; Case 3. Started at normal text: make every line an heading,
;; skipping headlines and items.
(t (let* ((stars