-;;; 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:
(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)))
(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)
;; 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