Browse Source

Little bug fix.

* org-list.el (org-list-struct-apply-struct): check if ancestor exists.
Nicolas Goaziou 15 years ago
parent
commit
e8967901fa
1 changed files with 2 additions and 1 deletions
  1. 2 1
      lisp/org-list.el

+ 2 - 1
lisp/org-list.el

@@ -1006,13 +1006,14 @@ BEGIN is included and END excluded."
   "Apply modifications to list so it mirrors STRUCT.
   "Apply modifications to list so it mirrors STRUCT.
 Initial position is restored after the changes."
 Initial position is restored after the changes."
   (let* ((pos (copy-marker (point)))
   (let* ((pos (copy-marker (point)))
+	 (ancestor (caar struct))
          (modify
          (modify
           (lambda (item)
           (lambda (item)
             (goto-char (car item))
             (goto-char (car item))
 	    (org-list-indent-item (nth 1 item))
 	    (org-list-indent-item (nth 1 item))
 	    (org-list-replace-bullet (org-list-bullet-string (nth 2 item)))))
 	    (org-list-replace-bullet (org-list-bullet-string (nth 2 item)))))
 	 ;; Remove ancestor if it is left.
 	 ;; Remove ancestor if it is left.
-	 (struct-to-apply (if (= 0 (caar struct)) (cdr struct) struct)))
+	 (struct-to-apply (if (or (not ancestor) (= 0 ancestor)) (cdr struct) struct)))
     ;; Apply changes from bottom to top
     ;; Apply changes from bottom to top
     (mapc modify (nreverse struct-to-apply))
     (mapc modify (nreverse struct-to-apply))
     (goto-char pos)))
     (goto-char pos)))