diff options
| author | Stefan Monnier | 2011-11-29 15:21:28 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2011-11-29 15:21:28 -0500 |
| commit | a1beca856defa17f648164fceb511cfb4bb71e63 (patch) | |
| tree | 421d9f4014ccb800bb391bc13b181edca29867c2 /lisp/align.el | |
| parent | 6288f0ca4e18a9eb599bc4200554841c2986b6e1 (diff) | |
| download | emacs-a1beca856defa17f648164fceb511cfb4bb71e63.tar.gz emacs-a1beca856defa17f648164fceb511cfb4bb71e63.zip | |
* lisp/align.el: Try to generate fewer markers.
(align--set-marker): New macro.
(align-region): Use it.
Fixes: debbugs:10047
Diffstat (limited to 'lisp/align.el')
| -rw-r--r-- | lisp/align.el | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lisp/align.el b/lisp/align.el index 8767b6ff306..0d9f351b9da 100644 --- a/lisp/align.el +++ b/lisp/align.el | |||
| @@ -1246,6 +1246,11 @@ have been aligned. No changes will be made to the buffer." | |||
| 1246 | (car props) (cdr props))))))))))) | 1246 | (car props) (cdr props))))))))))) |
| 1247 | (setq areas (cdr areas)))))) | 1247 | (setq areas (cdr areas)))))) |
| 1248 | 1248 | ||
| 1249 | (defmacro align--set-marker (marker-var pos &optional type) | ||
| 1250 | `(if ,marker-var | ||
| 1251 | (move-marker ,marker-var ,pos) | ||
| 1252 | (setq ,marker-var (copy-marker ,pos ,type)))) | ||
| 1253 | |||
| 1249 | (defun align-region (beg end separate rules exclude-rules | 1254 | (defun align-region (beg end separate rules exclude-rules |
| 1250 | &optional func) | 1255 | &optional func) |
| 1251 | "Align a region based on a given set of alignment rules. | 1256 | "Align a region based on a given set of alignment rules. |
| @@ -1370,8 +1375,8 @@ aligner would have dealt with are." | |||
| 1370 | (if (not here) | 1375 | (if (not here) |
| 1371 | (goto-char end)) | 1376 | (goto-char end)) |
| 1372 | (forward-line) | 1377 | (forward-line) |
| 1373 | (setq end (point) | 1378 | (setq end (point)) |
| 1374 | end-mark (copy-marker end t)) | 1379 | (align--set-marker end-mark end t) |
| 1375 | (goto-char beg))) | 1380 | (goto-char beg))) |
| 1376 | 1381 | ||
| 1377 | ;; If we have a region to align, and `func' is set and | 1382 | ;; If we have a region to align, and `func' is set and |
| @@ -1467,10 +1472,9 @@ aligner would have dealt with are." | |||
| 1467 | ;; test whether we have found a match on the same | 1472 | ;; test whether we have found a match on the same |
| 1468 | ;; line as a previous match | 1473 | ;; line as a previous match |
| 1469 | (if (> (point) eol) | 1474 | (if (> (point) eol) |
| 1470 | (setq same nil | 1475 | (progn |
| 1471 | eol (save-excursion | 1476 | (setq same nil) |
| 1472 | (end-of-line) | 1477 | (align--set-marker eol (line-end-position)))) |
| 1473 | (point-marker)))) | ||
| 1474 | 1478 | ||
| 1475 | ;; lookup the `repeat' attribute the first time | 1479 | ;; lookup the `repeat' attribute the first time |
| 1476 | (or repeat-c | 1480 | (or repeat-c |
| @@ -1504,10 +1508,9 @@ aligner would have dealt with are." | |||
| 1504 | (progn | 1508 | (progn |
| 1505 | (align-regions regions align-props | 1509 | (align-regions regions align-props |
| 1506 | rule func) | 1510 | rule func) |
| 1507 | (setq last-point (copy-marker b t) | 1511 | (setq regions nil) |
| 1508 | regions nil | 1512 | (setq align-props nil))) |
| 1509 | align-props nil)) | 1513 | (align--set-marker last-point b t) |
| 1510 | (setq last-point (copy-marker b t))) | ||
| 1511 | 1514 | ||
| 1512 | ;; restore the match data | 1515 | ;; restore the match data |
| 1513 | (set-match-data save-match-data) | 1516 | (set-match-data save-match-data) |