emacs-diffs
[Top][All Lists]
Advanced

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

master 2c9594a: * lisp/emulation/edt.el (edt-with-position): Don't bind


From: Stefan Monnier
Subject: master 2c9594a: * lisp/emulation/edt.el (edt-with-position): Don't bind `left`
Date: Thu, 11 Mar 2021 13:15:37 -0500 (EST)

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

    * lisp/emulation/edt.el (edt-with-position): Don't bind `left`
    
    (edt-find-forward, edt-find-next-forward, edt-sentence-forward)
    (edt-paragraph-forward): Adjust accordingly.
---
 lisp/emulation/edt.el | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/lisp/emulation/edt.el b/lisp/emulation/edt.el
index b8dea2f..8f90ed2 100644
--- a/lisp/emulation/edt.el
+++ b/lisp/emulation/edt.el
@@ -635,8 +635,7 @@ Argument NUM is the number of lines to move."
 
 (defmacro edt-with-position (&rest body)
   "Execute BODY with some position-related variables bound."
-  `(let* ((left nil)
-          (beg (edt-current-line))
+  `(let* ((beg (edt-current-line))
           (height (window-height))
           (top-percent
            (if (zerop edt-top-scroll-margin) 10 edt-top-scroll-margin))
@@ -650,7 +649,7 @@ Argument NUM is the number of lines to move."
           (far (save-excursion
                  (goto-char bottom)
                  (point-at-bol (1- height)))))
-     (ignore top left far)
+     (ignore top far)
      ,@body))
 
 ;;;
@@ -668,9 +667,10 @@ Optional argument FIND is t is this function is called 
from `edt-find'."
      (search-backward edt-find-last-text)
      (edt-set-match)
      (if (> (point) far)
-         (if (zerop (setq left (save-excursion (forward-line height))))
-             (recenter top-margin)
-           (recenter (- left bottom-up-margin)))
+         (let ((left (save-excursion (forward-line height))))
+           (recenter (if (zerop left)
+                         top-margin
+                       (- left bottom-up-margin))))
        (and (> (point) bottom) (recenter bottom-margin))))))
 
 (defun edt-find-backward (&optional find)
@@ -707,9 +707,9 @@ Optional argument FIND is t if this function is called from 
`edt-find'."
          (search-backward edt-find-last-text)
          (edt-set-match)
          (if (> (point) far)
-             (if (zerop (setq left (save-excursion (forward-line height))))
-                 (recenter top-margin)
-               (recenter (- left bottom-up-margin)))
+             (let ((left (save-excursion (forward-line height))))
+               (recenter (if (zerop left) top-margin
+                           (- left bottom-up-margin))))
            (and (> (point) bottom) (recenter bottom-margin))))
      (backward-char 1)
      (error "Search failed: \"%s\"" edt-find-last-text))))
@@ -1241,9 +1241,8 @@ Argument NUM is the positive number of sentences to move."
      (forward-word 1)
      (backward-sentence))
    (if (> (point) far)
-       (if (zerop (setq left (save-excursion (forward-line height))))
-           (recenter top-margin)
-         (recenter (- left bottom-up-margin)))
+       (let ((left (save-excursion (forward-line height))))
+         (recenter (if (zerop left) top-margin (- left bottom-up-margin))))
      (and (> (point) bottom) (recenter bottom-margin)))))
 
 (defun edt-sentence-backward (num)
@@ -1282,9 +1281,8 @@ Argument NUM is the positive number of paragraphs to 
move."
          (forward-line 1))
      (setq num (1- num)))
    (if (> (point) far)
-       (if (zerop (setq left (save-excursion (forward-line height))))
-           (recenter top-margin)
-         (recenter (- left bottom-up-margin)))
+       (let ((left (save-excursion (forward-line height))))
+         (recenter (if (zerop left) top-margin (- left bottom-up-margin))))
      (and (> (point) bottom) (recenter bottom-margin)))))
 
 (defun edt-paragraph-backward (num)



reply via email to

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