summaryrefslogtreecommitdiff
path: root/lisp/align.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2009-01-24 23:42:42 +0000
committerChong Yidong <cyd@stupidchicken.com>2009-01-24 23:42:42 +0000
commit5fe829521cfe73890a7ca3e5e39dac4ea21f51a1 (patch)
tree19fe9d1136364e822d7206293539736d729ed1fd /lisp/align.el
parent6ac30b5b14f4118bd3501a64f3f658500bce571c (diff)
downloademacs-5fe829521cfe73890a7ca3e5e39dac4ea21f51a1.tar.gz
(align-region): Avoid infloop.
Diffstat (limited to 'lisp/align.el')
-rw-r--r--lisp/align.el11
1 files changed, 9 insertions, 2 deletions
diff --git a/lisp/align.el b/lisp/align.el
index 911200f58ad..cb69bc51947 100644
--- a/lisp/align.el
+++ b/lisp/align.el
@@ -1307,6 +1307,7 @@ aligner would have dealt with are."
(rulesep (assq 'separate rule))
(thissep (if rulesep (cdr rulesep) separate))
same (eol 0)
+ search-start
group group-c
spacing spacing-c
tab-stop tab-stop-c
@@ -1412,6 +1413,7 @@ aligner would have dealt with are."
;; while we can find the rule in the alignment
;; region..
(while (and (< (point) end-mark)
+ (setq search-start (point))
(if regfunc
(funcall regfunc end-mark nil)
(re-search-forward regexp
@@ -1436,7 +1438,7 @@ aligner would have dealt with are."
;; if the search ended us on the beginning of
;; the next line, move back to the end of the
;; previous line.
- (if (bolp)
+ (if (and (bolp) (> (point) search-start))
(forward-char -1))
;; lookup the `group' attribute the first time
@@ -1576,7 +1578,12 @@ aligner would have dealt with are."
;; the next line; don't bother searching
;; anymore on this one
(if (and (not repeat) (not (bolp)))
- (forward-line)))))
+ (forward-line))
+
+ ;; if the search did not change point,
+ ;; move forward to avoid an infinite loop
+ (if (= (point) search-start)
+ (forward-char)))))
;; when they are no more matches for this rule,
;; align whatever was left over