changeset 73000:fea9765e7991

* simple.el (line-move-1): Escape field boundaries occurring exactly at point. Update goal column if constrained to a field. (line-move-finish): Escape field boundaries occurring exactly at point.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 19 Sep 2006 21:34:01 +0000
parents c983ed5a8049
children 2b055f644b75
files lisp/ChangeLog lisp/simple.el
diffstat 2 files changed, 26 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Sep 19 16:33:30 2006 +0000
+++ b/lisp/ChangeLog	Tue Sep 19 21:34:01 2006 +0000
@@ -1,3 +1,10 @@
+2006-09-19  Chong Yidong  <cyd@stupidchicken.com>
+
+	* simple.el (line-move-1): Escape field boundaries occurring
+	exactly at point.  Update goal column if constrained to a field.
+	(line-move-finish): Escape field boundaries occurring exactly at
+	point.
+
 2006-09-19  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* mouse.el (mouse-on-link-p): Tentatively fix last change.
--- a/lisp/simple.el	Tue Sep 19 16:33:30 2006 +0000
+++ b/lisp/simple.el	Tue Sep 19 21:34:01 2006 +0000
@@ -3561,7 +3561,7 @@
   ;; for intermediate positions.
   (let ((inhibit-point-motion-hooks t)
 	(opoint (point))
-	(forward (> arg 0)))
+	(orig-arg arg))
     (unwind-protect
 	(progn
 	  (if (not (memq last-command '(next-line previous-line)))
@@ -3594,14 +3594,27 @@
 			      'end-of-buffer)
 			    nil)))
 	    ;; Move by arg lines, but ignore invisible ones.
-	    (let (done)
+	    (let (done line-end)
 	      (while (and (> arg 0) (not done))
 		;; If the following character is currently invisible,
 		;; skip all characters with that same `invisible' property value.
 		(while (and (not (eobp)) (line-move-invisible-p (point)))
 		  (goto-char (next-char-property-change (point))))
-		;; Now move a line.
-		(end-of-line)
+		;; Move a line.
+		;; We don't use `end-of-line', since we want to escape
+		;; from field boundaries ocurring exactly at point.
+		(let ((inhibit-field-text-motion t))
+		  (setq line-end (line-end-position)))
+		(goto-char (constrain-to-field line-end (point) t t))
+		;; When moving a single line, update the goal-column
+		;; if we couldn't move to the end of line due to a
+		;; field boundary.  Otherwise we'll get stuck at the
+		;; original position during the column motion in
+		;; line-move-finish.
+		(and (/= line-end (point))
+		     (= orig-arg 1)
+		     (setq temporary-goal-column
+			   (max temporary-goal-column (current-column))))
 		;; If there's no invisibility here, move over the newline.
 		(cond
 		 ((eobp)
@@ -3659,7 +3672,7 @@
 	     (beginning-of-line))
 	    (t
 	     (line-move-finish (or goal-column temporary-goal-column)
-			       opoint forward))))))
+			       opoint (> orig-arg 0)))))))
 
 (defun line-move-finish (column opoint forward)
   (let ((repeat t))
@@ -3721,7 +3734,7 @@
 	(goto-char opoint)
 	(let ((inhibit-point-motion-hooks nil))
 	  (goto-char
-	   (constrain-to-field new opoint nil t
+	   (constrain-to-field new opoint t t
 			       'inhibit-line-move-field-capture)))
 
 	;; If all this moved us to a different line,