branch: externals/valign
commit cd7c17f3d5dbdb979a4c829eb028e678c0ed581b
Author: Yuan Fu <[email protected]>
Commit: Yuan Fu <[email protected]>
Fix infinite loop
* valign.el (valign--beginning-of-table, valign--end-of-table): Fix.
---
valign.el | 25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/valign.el b/valign.el
index 37e4850..7ead41e 100644
--- a/valign.el
+++ b/valign.el
@@ -302,16 +302,8 @@ Start from point, stop at LIMIT."
Assumes point is on a table. Return nil if failed, point
otherwise."
(beginning-of-line)
- (skip-chars-forward " \t")
- (if (not (eq (char-after) ?|))
- nil
- (while (and (eq (char-after) ?|)
- (eq (forward-line -1) 0))
- (beginning-of-line)
- (skip-chars-forward " \t"))
- (unless (eq (char-after) ?|)
- (search-forward "|")
- (backward-char))
+ (if (not (looking-at "[ \t]*|")) nil
+ (while (re-search-backward "^[ \t]*|" nil t))
(point)))
(defun valign--end-of-table ()
@@ -319,16 +311,9 @@ otherwise."
Assumes point is on a table. Return nil if failed, point
otherwise."
(beginning-of-line)
- (skip-chars-forward " \t")
- (if (not (eq (char-after) ?|))
- nil
- (while (and (eq (char-after) ?|)
- (eq (forward-line 1) 0))
- (beginning-of-line)
- (skip-chars-forward " \t"))
- (search-backward "|")
- (forward-char)
- (point)))
+ (if (not (looking-at "[ \t]*|")) nil
+ (while (re-search-forward "|[^|]*$" nil t))
+ (line-end-position)))
(defun valign--put-text-property (beg end xpos)
"Put text property on text from BEG to END.