emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 3ce07b1: Avoid infloop in rect.el


From: Eli Zaretskii
Subject: [Emacs-diffs] master 3ce07b1: Avoid infloop in rect.el
Date: Sat, 18 Feb 2017 04:32:53 -0500 (EST)

branch: master
commit 3ce07b18f9a65f961ce959b5af32d05714f5a802
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Avoid infloop in rect.el
    
    * lisp/rect.el (rectangle--*-char): Avoid inflooping when called
    with argument N whose absolute value is greater than 1.  (Bug#25773)
---
 lisp/rect.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lisp/rect.el b/lisp/rect.el
index a4fa282..a85101f 100644
--- a/lisp/rect.el
+++ b/lisp/rect.el
@@ -639,7 +639,8 @@ Activates the region if needed.  Only lasts until the 
region is deactivated."
   ;; rectangles" and not "visual rectangles", so in the presence of
   ;; bidirectional text things won't work well anyway.
   (if (< n 0) (rectangle--*-char other-cmd (- n))
-    (let ((col (rectangle--point-col (point))))
+    (let ((col (rectangle--point-col (point)))
+          (step 1))
       (while (> n 0)
         (let* ((bol (line-beginning-position))
                (eol (line-end-position))
@@ -647,7 +648,7 @@ Activates the region if needed.  Only lasts until the 
region is deactivated."
                (nextcol
                 (condition-case nil
                     (save-excursion
-                      (funcall cmd 1)
+                      (funcall cmd step)
                       (cond
                        ((> bol (point)) (- curcol 1))
                        ((< eol (point)) (+ col (1+ n)))
@@ -666,7 +667,8 @@ Activates the region if needed.  Only lasts until the 
region is deactivated."
            (t ;; (> nextcol curcol)
             (if (<= diff n)
                 (progn (cl-decf n diff) (setq col nextcol))
-              (setq col (if (< col nextcol) (+ col n) (- col n)) n 0))))))
+              (setq col (if (< col nextcol) (+ col n) (- col n)) n 0))))
+          (setq step (1+ step))))
       ;; FIXME: This rectangle--col-pos's move-to-column is wasted!
       (rectangle--col-pos col 'point))))
 



reply via email to

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