changeset 30254:857a458d569d

Added a new feature to align.el
author John Wiegley <johnw@newartisans.com>
date Mon, 17 Jul 2000 06:33:36 +0000
parents 4e276b9c8239
children ed4c1e5caf4b
files lisp/ChangeLog lisp/align.el
diffstat 2 files changed, 34 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Jul 17 01:27:07 2000 +0000
+++ b/lisp/ChangeLog	Mon Jul 17 06:33:36 2000 +0000
@@ -1,3 +1,9 @@
+2000-07-16  John Wiegley  <johnw@gnu.org.
+
+	* lisp/align.el (align-newline-and-indent): Adding new function
+	for auto-aligning blocks of code on RET.
+	(align-region): Fixed badly formatted minibuffer message.
+
 2000-07-17  Kenichi Handa  <handa@etl.go.jp>
 
 	* international/kkc.el (kkc-show-conversion-list-count): Customize
--- a/lisp/align.el	Mon Jul 17 01:27:07 2000 +0000
+++ b/lisp/align.el	Mon Jul 17 06:33:36 2000 +0000
@@ -1033,6 +1033,23 @@
     (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 (symbolp 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 +1411,17 @@
 			;; 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