]> git.eshelyaron.com Git - emacs.git/commitdiff
(line-move-1): Obey `inhibit-point-motion-hooks`
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 7 Oct 2022 16:51:14 +0000 (12:51 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 7 Oct 2022 16:51:14 +0000 (12:51 -0400)
`line-move-1` was written back before `inhibit-point-motion-hooks`
was made obsolete and it's written under the assumption that its
value is nil, whereas since Emacs-25 it's t.

To work around problems linked to a nil value of
`inhibit-point-motion-hooks`, the code temporarily binds that var to
t while it moves around trying to find the final destination and then
later in a few key spots it binds it "back" to nil so as to run the
point-motion hooks according to the final destination, as if the
overall motion had been made "normally".

Change the code so that the "bind back" indeed binds the var back to
the value it had originally, rather than always to nil.

* lisp/simple.el (line-move-1): Obey `inhibit-point-motion-hooks`
(line-move-finish): New optional arg `not-ipmh`.

lisp/simple.el

index 7556b5adcfd719612e929d035f45e1e358466d8c..49ce95dfcfcaac8ef9cecfef124bcda8057de8a5 100644 (file)
@@ -7837,7 +7837,8 @@ If NOERROR, don't signal an error if we can't move that many lines."
 (defun line-move-1 (arg &optional noerror _to-end)
   ;; Don't run any point-motion hooks, and disregard intangibility,
   ;; for intermediate positions.
-  (let ((inhibit-point-motion-hooks t)
+  (let ((outer-ipmh inhibit-point-motion-hooks)
+       (inhibit-point-motion-hooks t)
        (opoint (point))
        (orig-arg arg))
     (if (consp temporary-goal-column)
@@ -7949,20 +7950,20 @@ If NOERROR, don't signal an error if we can't move that many lines."
             ;; point-left-hooks.
             (let* ((npoint (prog1 (line-end-position)
                              (goto-char opoint)))
-                   (inhibit-point-motion-hooks nil))
+                   (inhibit-point-motion-hooks outer-ipmh))
               (goto-char npoint)))
            ((< arg 0)
             ;; If we did not move up as far as desired,
             ;; at least go to beginning of line.
             (let* ((npoint (prog1 (line-beginning-position)
                              (goto-char opoint)))
-                   (inhibit-point-motion-hooks nil))
+                   (inhibit-point-motion-hooks outer-ipmh))
               (goto-char npoint)))
            (t
             (line-move-finish (or goal-column temporary-goal-column)
-                              opoint (> orig-arg 0)))))))
+                              opoint (> orig-arg 0) (not outer-ipmh)))))))
 
-(defun line-move-finish (column opoint forward)
+(defun line-move-finish (column opoint forward &optional not-ipmh)
   (let ((repeat t))
     (while repeat
       ;; Set REPEAT to t to repeat the whole thing.
@@ -8013,7 +8014,7 @@ If NOERROR, don't signal an error if we can't move that many lines."
        ;; unnecessarily.  Note that we move *forward* past intangible
        ;; text when the initial and final points are the same.
        (goto-char new)
-       (let ((inhibit-point-motion-hooks nil))
+       (let ((inhibit-point-motion-hooks (not not-ipmh)))
          (goto-char new)
 
          ;; If intangibility moves us to a different (later) place
@@ -8038,7 +8039,7 @@ If NOERROR, don't signal an error if we can't move that many lines."
        ;; Now move to the updated destination, processing fields
        ;; as well as intangibility.
        (goto-char opoint)
-       (let ((inhibit-point-motion-hooks nil))
+       (let ((inhibit-point-motion-hooks (not not-ipmh)))
          (goto-char
           ;; Ignore field boundaries if the initial and final
           ;; positions have the same `field' property, even if the