]> code.delx.au - gnu-emacs/blobdiff - lisp/align.el
(save-abbrevs, save-some-buffers): Don't ask the user
[gnu-emacs] / lisp / align.el
index d3195b443659c2e4a16aa6774c88ca2dc978a56f..ad4bd039661edc04a85913e3a9326b211845338b 100644 (file)
@@ -1,10 +1,9 @@
-;;; align --- align text to a specific column, by regexp
+;;; align.el --- align text to a specific column, by regexp
 
 ;; Copyright (C) 1999, 2000 Free Sofware Foundation
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;; Keywords: convenience languages lisp
-;; X-URL: http://www.emacs.org/~johnw/emacs.html
 
 ;; This file is part of GNU Emacs.
 
 
 (defgroup align nil
   "Align text to a specific column, by regexp."
+  :version "21.1"
   :group 'fill)
 
 ;;; User Variables:
@@ -872,7 +872,8 @@ on the format of these lists."
   (interactive "r")
   (let ((separator
         (or separate
-            (if (symbolp align-region-separate)
+            (if (and (symbolp align-region-separate)
+                     (boundp align-region-separate))
                 (symbol-value align-region-separate)
               align-region-separate)
             'entire)))
@@ -1033,6 +1034,24 @@ to be colored."
     (setq align-highlight-overlays
          (cdr align-highlight-overlays))))
 
+;;;###autoload
+(defun align-newline-and-indent ()
+  "A replacement function for `newline-and-indent', aligning as it goes."
+  (interactive)
+  (let ((separate (or (if (and (symbolp align-region-separate)
+                              (boundp align-region-separate))
+                         (symbol-value align-region-separate)
+                       align-region-separate)
+                     'entire))
+       (end (point)))
+    (call-interactively 'newline-and-indent)
+    (save-excursion
+      (forward-line -1)
+      (while (not (or (bobp)
+                     (align-new-section-p (point) end separate)))
+       (forward-line -1))
+      (align (point) end))))
+
 ;;; Internal Functions:
 
 (defun align-match-tex-pattern (regexp end &optional reverse)
@@ -1394,12 +1413,17 @@ aligner would have dealt with are."
                        ;; are, if it's a very large region being
                        ;; aligned
                        (if report
-                           (message
-                            "Aligning `%s' [rule %d of %d] (%d%%)..."
-                            (symbol-name (car rule))
-                            rule-index rule-count
-                            (/ (* (- (point) real-beg) 100)
-                               (- end-mark real-beg))))
+                           (let ((name (symbol-name (car rule))))
+                             (if name
+                                 (message
+                                  "Aligning `%s' (rule %d of %d) %d%%..."
+                                  rule-index rule-count
+                                  (/ (* (- (point) real-beg) 100)
+                                     (- end-mark real-beg)))
+                               (message
+                                "Aligning %d%%..."
+                                (/ (* (- (point) real-beg) 100)
+                                   (- end-mark real-beg))))))
 
                        ;; if the search ended us on the beginning of
                        ;; the next line, move back to the end of the