Browse Source

C-c C-c also repairs ill-formed lists

* lisp/org-list.el (org-list-struct): mark items less indented than
  top item of the list, so that they will be modified.
(org-list-struct-apply-struct): compare struct's indentation with
  line's indentation instead of old-struct's. This is needed because
  `org-list-struct' automatically fixes indentation so changes might not
  be seen otherwise.
* lisp/org.el (org-ctrl-c-ctrl-c): small refactoring.
Nicolas Goaziou 14 years ago
parent
commit
69cc51fa43
2 changed files with 8 additions and 4 deletions
  1. 7 3
      lisp/org-list.el
  2. 1 1
      lisp/org.el

+ 7 - 3
lisp/org-list.el

@@ -800,8 +800,12 @@ Assume point is at an item."
       ;;    indented.
       (let ((min-ind (nth 1 (car struct))))
 	(mapc (lambda (item)
-		(let ((ind (nth 1 item)))
-		  (when (< ind min-ind) (setcar (cdr item) min-ind))))
+		(let ((ind (nth 1 item))
+		      (bul (nth 2 item)))
+		  (when (< ind min-ind)
+		    (setcar (cdr item) min-ind)
+		    ;; Modify bullet to be sure item will be modified
+		    (setcar (nthcdr 2 item) (org-trim bul)))))
 	      struct))
       ;; 4. Associate each item to its end pos.
       (org-list-struct-assoc-end struct end-lst)
@@ -1616,7 +1620,7 @@ Initial position of cursor is restored after the changes."
 	   (lambda (item)
 	     (goto-char item)
 	     (let* ((new-ind (org-list-get-ind item struct))
-		    (old-ind (org-list-get-ind item old-struct))
+		    (old-ind (org-get-indentation))
 		    (new-bul (org-list-bullet-string
 			      (org-list-get-bullet item struct)))
 		    (old-bul (org-list-get-bullet item old-struct))

+ 1 - 1
lisp/org.el

@@ -17429,7 +17429,7 @@ This command does many different things, depending on context:
       ;; Do checkbox related actions only if function was called with
       ;; an argument
       (let* ((struct (org-list-struct))
-	     (old-struct (mapcar (lambda (e) (copy-alist e)) struct))
+	     (old-struct (copy-tree struct))
 	     (parents (org-list-parents-alist struct))
 	     (prevs (org-list-prevs-alist struct)))
 	(org-list-struct-fix-ind struct parents)