]> git.eshelyaron.com Git - emacs.git/commitdiff
(move-beginning-of-line): Test whether fields
authorRichard M. Stallman <rms@gnu.org>
Wed, 16 Aug 2006 05:07:22 +0000 (05:07 +0000)
committerRichard M. Stallman <rms@gnu.org>
Wed, 16 Aug 2006 05:07:22 +0000 (05:07 +0000)
would prevent motion back to line's first visible character.
If so, stop where the fields would stop the motion.

lisp/simple.el

index 9288ab6bd79eab72a1dbe413922f8342d22c1901..f1b80968ff13b05e4db85ad1531c16bcd724badc 100644 (file)
@@ -3770,7 +3770,8 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
   (interactive "p")
   (or arg (setq arg 1))
 
-  (let ((orig (point)))
+  (let ((orig (point))
+       start first-vis first-vis-field-value)
 
     ;; Move by lines, if ARG is not 1 (the default).
     (if (/= arg 1)
@@ -3781,10 +3782,24 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t."
     (while (and (not (bobp)) (line-move-invisible-p (1- (point))))
       (goto-char (previous-char-property-change (point)))
       (skip-chars-backward "^\n"))
-
-    ;; Take care of fields.
-    (goto-char (constrain-to-field (point) orig
-                                  (/= arg 1) t nil))))
+    (setq start (point))
+
+    ;; Now find first visible char in the line
+    (while (and (not (eobp)) (line-move-invisible-p (point)))
+      (goto-char (next-char-property-change (point))))
+    (setq first-vis (point))
+
+    ;; See if fields would stop us from reaching FIRST-VIS.
+    (setq first-vis-field-value
+         (constrain-to-field first-vis orig (/= arg 1) t nil))
+
+    (goto-char (if (/= first-vis-field-value first-vis)
+                  ;; If yes, obey them.
+                  first-vis-field-value
+                ;; Otherwise, move to START with attention to fields.
+                ;; (It is possible that fields never matter in this case.)
+                (constrain-to-field (point) orig
+                                    (/= arg 1) t nil)))))
 
 
 ;;; Many people have said they rarely use this feature, and often type