emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs/lisp align.el


From: Chong Yidong
Subject: [Emacs-diffs] emacs/lisp align.el
Date: Sat, 24 Jan 2009 23:42:42 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Chong Yidong <cyd>      09/01/24 23:42:42

Modified files:
        lisp           : align.el 

Log message:
        (align-region): Avoid infloop.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/align.el?cvsroot=emacs&r1=1.33&r2=1.34

Patches:
Index: align.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/align.el,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- align.el    5 Jan 2009 03:18:39 -0000       1.33
+++ align.el    24 Jan 2009 23:42:42 -0000      1.34
@@ -1307,6 +1307,7 @@
                 (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 @@
                      ;; 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 @@
                        ;; 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 @@
                            ;; 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




reply via email to

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