]> code.delx.au - gnu-emacs/blobdiff - lisp/align.el
* appt.el: Restore significant whitespace deleted by "spelling fix".
[gnu-emacs] / lisp / align.el
index 0dff2873e9e778c182f1f66f5db547accea559ae..0d9f351b9dac5fc81b1e6606318da36aafb0468d 100644 (file)
@@ -1,7 +1,6 @@
 ;;; align.el --- align text to a specific column, by regexp
 
 ;;; align.el --- align text to a specific column, by regexp
 
-;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008, 2009, 2010, 2011  Free Software Foundation, Inc.
+;; Copyright (C) 1999-2011  Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Maintainer: FSF
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Maintainer: FSF
@@ -1107,7 +1106,7 @@ documentation for `align-region-separate' for more details."
             (setq seps (cdr seps))))
           yes))))
 
             (setq seps (cdr seps))))
           yes))))
 
-(defun align-adjust-col-for-rule (column rule spacing tab-stop)
+(defun align-adjust-col-for-rule (column _rule spacing tab-stop)
   "Adjust COLUMN according to the given RULE.
 SPACING specifies how much spacing to use.
 TAB-STOP specifies whether SPACING refers to tab-stop boundaries."
   "Adjust COLUMN according to the given RULE.
 SPACING specifies how much spacing to use.
 TAB-STOP specifies whether SPACING refers to tab-stop boundaries."
@@ -1162,7 +1161,7 @@ have been aligned.  No changes will be made to the buffer."
         (justify (cdr (assq 'justify rule)))
         (col (or fixed 0))
         (width 0)
         (justify (cdr (assq 'justify rule)))
         (col (or fixed 0))
         (width 0)
-        ecol change look)
+        ecol change)
 
     ;; Determine the alignment column.
     (let ((a areas))
 
     ;; Determine the alignment column.
     (let ((a areas))
@@ -1247,6 +1246,11 @@ have been aligned.  No changes will be made to the buffer."
                                         (car props) (cdr props)))))))))))
        (setq areas (cdr areas))))))
 
                                         (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.
 (defun align-region (beg end separate rules exclude-rules
                         &optional func)
   "Align a region based on a given set of alignment rules.
@@ -1286,7 +1290,6 @@ purpose where you might want to know where the regions that the
 aligner would have dealt with are."
   (let ((end-mark (and end (copy-marker end t)))
        (real-beg beg)
 aligner would have dealt with are."
   (let ((end-mark (and end (copy-marker end t)))
        (real-beg beg)
-       (real-end end)
        (report (and (not func) align-large-region beg end
                     (>= (- end beg) align-large-region)))
        (rule-index 1)
        (report (and (not func) align-large-region beg end
                     (>= (- end beg) align-large-region)))
        (rule-index 1)
@@ -1315,7 +1318,7 @@ aligner would have dealt with are."
                 tab-stop tab-stop-c
                 repeat repeat-c
                 valid valid-c
                 tab-stop tab-stop-c
                 repeat repeat-c
                 valid valid-c
-                pos-list first
+                first
                 regions index
                 last-point b e
                 save-match-data
                 regions index
                 last-point b e
                 save-match-data
@@ -1372,8 +1375,8 @@ aligner would have dealt with are."
                  (if (not here)
                      (goto-char end))
                  (forward-line)
                  (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
                  (goto-char beg)))
 
              ;; If we have a region to align, and `func' is set and
@@ -1469,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)
                        ;; 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
 
                        ;; lookup the `repeat' attribute the first time
                        (or repeat-c
@@ -1506,10 +1508,9 @@ aligner would have dealt with are."
                              (progn
                                (align-regions regions align-props
                                               rule func)
                              (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)
 
                          ;; restore the match data
                          (set-match-data save-match-data)