Browse Source

When moving items, keep the column position.

Reported by Rainer Stengele.
Carsten Dominik 17 years ago
parent
commit
46246169bf
2 changed files with 16 additions and 5 deletions
  1. 3 0
      lisp/ChangeLog
  2. 13 5
      lisp/org-list.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2008-09-29  Carsten Dominik  <dominik@science.uva.nl>
 2008-09-29  Carsten Dominik  <dominik@science.uva.nl>
 
 
+	* org-list.el (org-move-item-down, org-move-item-up): Remember and
+	restore the column of the cursor position.
+
 	* org-remember.el (org-remember-apply-template): Remove properties
 	* org-remember.el (org-remember-apply-template): Remove properties
 	from `initial'.
 	from `initial'.
 
 

+ 13 - 5
lisp/org-list.el

@@ -457,7 +457,9 @@ Error if not at a plain list, or if this is the first item in the list."
 Subitems (items with larger indentation) are considered part of the item,
 Subitems (items with larger indentation) are considered part of the item,
 so this really moves item trees."
 so this really moves item trees."
   (interactive)
   (interactive)
-  (let (beg beg0 end end0 ind ind1 (pos (point)) txt ne-end ne-beg)
+  (let ((col (current-column))
+	(pos (point))
+	beg beg0 end end0 ind ind1  txt ne-end ne-beg)
     (org-beginning-of-item)
     (org-beginning-of-item)
     (setq beg0 (point))
     (setq beg0 (point))
     (save-excursion
     (save-excursion
@@ -488,8 +490,10 @@ so this really moves item trees."
 	  (setq pos (point))
 	  (setq pos (point))
 	  (insert txt)
 	  (insert txt)
 	  (goto-char pos) (org-skip-whitespace)
 	  (goto-char pos) (org-skip-whitespace)
-	  (org-maybe-renumber-ordered-list))
+	  (org-maybe-renumber-ordered-list)
+	  (move-to-column col))
       (goto-char pos)
       (goto-char pos)
+      (move-to-column col)
       (error "Cannot move this item further down"))))
       (error "Cannot move this item further down"))))
 
 
 (defun org-move-item-up (arg)
 (defun org-move-item-up (arg)
@@ -497,8 +501,9 @@ so this really moves item trees."
 Subitems (items with larger indentation) are considered part of the item,
 Subitems (items with larger indentation) are considered part of the item,
 so this really moves item trees."
 so this really moves item trees."
   (interactive "p")
   (interactive "p")
-  (let (beg beg0 end ind ind1 (pos (point)) txt
-	    ne-beg ne-ins ins-end)
+  (let ((col (current-column)) (pos (point))
+	beg beg0 end ind ind1  txt
+	ne-beg ne-ins ins-end)
     (org-beginning-of-item)
     (org-beginning-of-item)
     (setq beg0 (point))
     (setq beg0 (point))
     (setq ind (org-get-indentation))
     (setq ind (org-get-indentation))
@@ -524,6 +529,7 @@ so this really moves item trees."
     (condition-case nil
     (condition-case nil
 	(org-beginning-of-item)
 	(org-beginning-of-item)
       (error (goto-char beg0)
       (error (goto-char beg0)
+	     (move-to-column col)
 	     (error "Cannot move this item further up")))
 	     (error "Cannot move this item further up")))
     (setq ind1 (org-get-indentation))
     (setq ind1 (org-get-indentation))
     (if (and (org-at-item-p) (= ind ind1))
     (if (and (org-at-item-p) (= ind ind1))
@@ -545,8 +551,10 @@ so this really moves item trees."
 		(kill-line (- ne-ins ne-beg)) (point)))
 		(kill-line (- ne-ins ne-beg)) (point)))
 	    (insert (make-string (- ne-ins ne-beg) ?\n)))
 	    (insert (make-string (- ne-ins ne-beg) ?\n)))
 
 
-	  (org-maybe-renumber-ordered-list))
+	  (org-maybe-renumber-ordered-list)
+	  (move-to-column col))
       (goto-char pos)
       (goto-char pos)
+      (move-to-column col)
       (error "Cannot move this item further up"))))
       (error "Cannot move this item further up"))))
 
 
 (defun org-maybe-renumber-ordered-list ()
 (defun org-maybe-renumber-ordered-list ()