diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2011-11-29 15:21:28 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 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.tar.bz2 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." (car props) (cdr props))))))))))) (setq areas (cdr areas)))))) +(defmacro align--set-marker (marker-var pos &optional type) + `(if ,marker-var + (move-marker ,marker-var ,pos) + (setq ,marker-var (copy-marker ,pos ,type)))) + (defun align-region (beg end separate rules exclude-rules &optional func) "Align a region based on a given set of alignment rules. @@ -1370,8 +1375,8 @@ aligner would have dealt with are." (if (not here) (goto-char end)) (forward-line) - (setq end (point) - end-mark (copy-marker end t)) + (setq end (point)) + (align--set-marker end-mark end t) (goto-char beg))) ;; If we have a region to align, and `func' is set and @@ -1467,10 +1472,9 @@ aligner would have dealt with are." ;; test whether we have found a match on the same ;; line as a previous match (if (> (point) eol) - (setq same nil - eol (save-excursion - (end-of-line) - (point-marker)))) + (progn + (setq same nil) + (align--set-marker eol (line-end-position)))) ;; lookup the `repeat' attribute the first time (or repeat-c @@ -1504,10 +1508,9 @@ aligner would have dealt with are." (progn (align-regions regions align-props rule func) - (setq last-point (copy-marker b t) - regions nil - align-props nil)) - (setq last-point (copy-marker b t))) + (setq regions nil) + (setq align-props nil))) + (align--set-marker last-point b t) ;; restore the match data (set-match-data save-match-data) |