Browse Source

org-list: clean left-over markers

* lisp/org-list.el (org-list-send-item, org-list-struct-apply-struct,
  org-apply-on-list, org-toggle-checkbox): make markers point nowhere
  when they have become useless.
Nicolas Goaziou 14 years ago
parent
commit
f7f2394448
1 changed files with 11 additions and 10 deletions
  1. 11 10
      lisp/org-list.el

+ 11 - 10
lisp/org-list.el

@@ -1454,8 +1454,7 @@ This function returns, destructively, the new list structure."
 							 (+ end shift)))))))
 							 (+ end shift)))))))
 			       moved-items))
 			       moved-items))
 		      (lambda (e1 e2) (< (car e1) (car e2))))))
 		      (lambda (e1 e2) (< (car e1) (car e2))))))
-      ;; 2. Eventually delete the extra copy of the item and clean
-      ;;    marker.
+      ;; 2. Eventually delete extra copy of the item and clean marker.
       (prog1
       (prog1
 	  (org-list-delete-item (marker-position item) struct)
 	  (org-list-delete-item (marker-position item) struct)
 	(move-marker item nil)))
 	(move-marker item nil)))
@@ -1756,7 +1755,7 @@ the structure to be applied.  The function will only modify parts
 of the list which have changed.
 of the list which have changed.
 
 
 Initial position of cursor is restored after the changes."
 Initial position of cursor is restored after the changes."
-  (let* ((pos (copy-marker (point)))
+  (let* ((origin (copy-marker (point)))
 	 (inlinetask-re (and (featurep 'org-inlinetask)
 	 (inlinetask-re (and (featurep 'org-inlinetask)
 			     (org-inlinetask-outline-regexp)))
 			     (org-inlinetask-outline-regexp)))
 	 (item-re (org-item-re))
 	 (item-re (org-item-re))
@@ -1867,8 +1866,9 @@ Initial position of cursor is restored after the changes."
 		(unless (or (not cell) (equal cell (assq beg old-struct)))
 		(unless (or (not cell) (equal cell (assq beg old-struct)))
 		  (funcall modify-item beg))))
 		  (funcall modify-item beg))))
 	    sliced-struct))
 	    sliced-struct))
-    ;; 4. Go back to initial position.
-    (goto-char pos)))
+    ;; 4. Go back to initial position and clean marker.
+    (goto-char origin)
+    (move-marker origin nil)))
 
 
 (defun org-list-write-struct (struct parents)
 (defun org-list-write-struct (struct parents)
   "Correct bullets, checkboxes and indentation in list at point.
   "Correct bullets, checkboxes and indentation in list at point.
@@ -1942,6 +1942,7 @@ beginning of the item."
 	    (setq value (apply function value args)))
 	    (setq value (apply function value args)))
 	  (nreverse all))
 	  (nreverse all))
     (goto-char item)
     (goto-char item)
+    (move-marker item nil)
     value))
     value))
 
 
 (defun org-list-set-item-visibility (item struct view)
 (defun org-list-set-item-visibility (item struct view)
@@ -2289,11 +2290,9 @@ in subtree, ignoring drawers."
 		 ((equal "[X]" cbox) "[ ]")
 		 ((equal "[X]" cbox) "[ ]")
 		 (t "[X]"))))))
 		 (t "[X]"))))))
       ;; When an item is found within bounds, grab the full list at
       ;; When an item is found within bounds, grab the full list at
-      ;; point structure, then:
-      ;; 1. set check-box of all its items within bounds to
-      ;;    REF-CHECKBOX;
-      ;; 2. fix check-boxes of the whole list; 3. move point after the
-      ;;    list.
+      ;; point structure, then: (1) set check-box of all its items
+      ;; within bounds to REF-CHECKBOX, (2) fix check-boxes of the
+      ;; whole list, (3) move point after the list.
       (goto-char lim-up)
       (goto-char lim-up)
       (while (and (< (point) lim-down)
       (while (and (< (point) lim-down)
 		  (org-list-search-forward (org-item-beginning-re)
 		  (org-list-search-forward (org-item-beginning-re)
@@ -2330,6 +2329,8 @@ in subtree, ignoring drawers."
 	     "Checkboxes were removed due to unchecked box at line %d"
 	     "Checkboxes were removed due to unchecked box at line %d"
 	     (org-current-line block-item))))
 	     (org-current-line block-item))))
 	  (goto-char bottom)
 	  (goto-char bottom)
+	  (move-marker lim-down nil)
+	  (move-marker bottom nil)
 	  (org-list-struct-apply-struct struct struct-copy)))))
 	  (org-list-struct-apply-struct struct struct-copy)))))
   (org-update-checkbox-count-maybe))
   (org-update-checkbox-count-maybe))