emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/valign 638f978 054/198: Fix infinite loop!!


From: Stefan Monnier
Subject: [elpa] externals/valign 638f978 054/198: Fix infinite loop!!
Date: Tue, 1 Dec 2020 18:19:15 -0500 (EST)

branch: externals/valign
commit 638f9784cf7b6b2ace9d9ec8956bb1ca185eced0
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Fix infinite loop!!
    
    * (valign--beginning-of-table, valign--end-of-table): Fix.
---
 valign.el | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/valign.el b/valign.el
index 0bc50d9..79eab0c 100644
--- a/valign.el
+++ b/valign.el
@@ -303,17 +303,29 @@ Assumes point is on a table.  Return nil if failed, point
 otherwise."
   (beginning-of-line)
   (if (not (looking-at "[ \t]*|")) nil
-    (while (re-search-backward "^[ \t]*|" nil t))
+    (condition-case nil
+        (while (looking-at "[ \t]*|")
+          (search-backward "\n")
+          (beginning-of-line))
+      (search-failed nil))
     (point)))
 
 (defun valign--end-of-table ()
   "Go forward to the end of the table at point.
 Assumes point is on a table.  Return nil if failed, point
 otherwise."
-  (beginning-of-line)
-  (if (not (looking-at "[ \t]*|")) nil
-    (while (re-search-forward "|[^|\n]*$" nil t))
-    (point)))
+  (let ((p (point)))
+    (beginning-of-line)
+    (if (not (looking-at "[ \t]*|"))
+        (progn (goto-char p) nil)
+      (condition-case nil
+          (while (looking-at "[ \t]*|")
+            ;; Each iteration the point is at BOL.
+            (search-forward "\n" nil))
+        (search-failed nil))
+      ;; Point at the line after the last line of the table.
+      (backward-char)
+      (point))))
 
 (defun valign--put-text-property (beg end xpos)
   "Put text property on text from BEG to END.



reply via email to

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