emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 3bf53ad05c: (line-move-1): Obey `inhibit-point-motion-hooks`


From: Stefan Monnier
Subject: master 3bf53ad05c: (line-move-1): Obey `inhibit-point-motion-hooks`
Date: Fri, 7 Oct 2022 12:51:22 -0400 (EDT)

branch: master
commit 3bf53ad05c60794bc4586d2c7afd8bfa11ba99c7
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    (line-move-1): Obey `inhibit-point-motion-hooks`
    
    `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 | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lisp/simple.el b/lisp/simple.el
index 7556b5adcf..49ce95dfcf 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]