Mercurial > emacs
comparison lisp/align.el @ 101449:577a3b5b05f5
(align-region): Avoid infloop.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 24 Jan 2009 23:42:42 +0000 |
parents | a9dc0e7c3f2b |
children | c4853c1bf38c |
comparison
equal
deleted
inserted
replaced
101448:d6d07d783be3 | 101449:577a3b5b05f5 |
---|---|
1305 (regexp (cdr (assq 'regexp rule))) | 1305 (regexp (cdr (assq 'regexp rule))) |
1306 (regfunc (and (functionp regexp) regexp)) | 1306 (regfunc (and (functionp regexp) regexp)) |
1307 (rulesep (assq 'separate rule)) | 1307 (rulesep (assq 'separate rule)) |
1308 (thissep (if rulesep (cdr rulesep) separate)) | 1308 (thissep (if rulesep (cdr rulesep) separate)) |
1309 same (eol 0) | 1309 same (eol 0) |
1310 search-start | |
1310 group group-c | 1311 group group-c |
1311 spacing spacing-c | 1312 spacing spacing-c |
1312 tab-stop tab-stop-c | 1313 tab-stop tab-stop-c |
1313 repeat repeat-c | 1314 repeat repeat-c |
1314 valid valid-c | 1315 valid valid-c |
1410 (setq case-fold-search (cdr case-fold))) | 1411 (setq case-fold-search (cdr case-fold))) |
1411 | 1412 |
1412 ;; while we can find the rule in the alignment | 1413 ;; while we can find the rule in the alignment |
1413 ;; region.. | 1414 ;; region.. |
1414 (while (and (< (point) end-mark) | 1415 (while (and (< (point) end-mark) |
1416 (setq search-start (point)) | |
1415 (if regfunc | 1417 (if regfunc |
1416 (funcall regfunc end-mark nil) | 1418 (funcall regfunc end-mark nil) |
1417 (re-search-forward regexp | 1419 (re-search-forward regexp |
1418 end-mark t))) | 1420 end-mark t))) |
1419 | 1421 |
1434 (- end-mark real-beg)))))) | 1436 (- end-mark real-beg)))))) |
1435 | 1437 |
1436 ;; if the search ended us on the beginning of | 1438 ;; if the search ended us on the beginning of |
1437 ;; the next line, move back to the end of the | 1439 ;; the next line, move back to the end of the |
1438 ;; previous line. | 1440 ;; previous line. |
1439 (if (bolp) | 1441 (if (and (bolp) (> (point) search-start)) |
1440 (forward-char -1)) | 1442 (forward-char -1)) |
1441 | 1443 |
1442 ;; lookup the `group' attribute the first time | 1444 ;; lookup the `group' attribute the first time |
1443 ;; that we need it | 1445 ;; that we need it |
1444 (unless group-c | 1446 (unless group-c |
1574 | 1576 |
1575 ;; if `repeat' has not been set, move to | 1577 ;; if `repeat' has not been set, move to |
1576 ;; the next line; don't bother searching | 1578 ;; the next line; don't bother searching |
1577 ;; anymore on this one | 1579 ;; anymore on this one |
1578 (if (and (not repeat) (not (bolp))) | 1580 (if (and (not repeat) (not (bolp))) |
1579 (forward-line))))) | 1581 (forward-line)) |
1582 | |
1583 ;; if the search did not change point, | |
1584 ;; move forward to avoid an infinite loop | |
1585 (if (= (point) search-start) | |
1586 (forward-char))))) | |
1580 | 1587 |
1581 ;; when they are no more matches for this rule, | 1588 ;; when they are no more matches for this rule, |
1582 ;; align whatever was left over | 1589 ;; align whatever was left over |
1583 (if regions | 1590 (if regions |
1584 (align-regions regions align-props rule func))) | 1591 (align-regions regions align-props rule func))) |