(tree-widget-super-format-handler)
[bpt/emacs.git] / lisp / align.el
index 40c3dec..563e839 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
+;; Copyright (C) 1999, 2000, 2002 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:
@@ -466,13 +466,13 @@ The possible settings for `align-region-separate' are:
      (repeat   . t)
      (modes    . align-c++-modes)
      (run-if   . ,(function (lambda () current-prefix-arg))))
-;      (valid
-;       . ,(function
-;        (lambda ()
-;          (memq (caar (c-guess-basic-syntax))
-;                '(brace-list-intro
-;                  brace-list-entry
-;                  brace-entry-open))))))
+                                       ;      (valid
+                                       ;       . ,(function
+                                       ;         (lambda ()
+                                       ;           (memq (caar (c-guess-basic-syntax))
+                                       ;                 '(brace-list-intro
+                                       ;                   brace-list-entry
+                                       ;                   brace-entry-open))))))
 
     ;; With a prefix argument, comma delimiter will be aligned.  Since
     ;; perl-mode doesn't give us enough syntactic information (and we
@@ -525,11 +525,11 @@ The possible settings for `align-region-separate' are:
      (regexp   . "\\(\\s-*\\)\\\\$")
      (modes    . align-c++-modes)
      (column   . c-backslash-column))
-;      (valid
-;       . ,(function
-;        (lambda ()
-;          (memq (caar (c-guess-basic-syntax))
-;                '(cpp-macro cpp-macro-cont))))))
+                                       ;      (valid
+                                       ;       . ,(function
+                                       ;         (lambda ()
+                                       ;           (memq (caar (c-guess-basic-syntax))
+                                       ;                 '(cpp-macro cpp-macro-cont))))))
 
     (basic-line-continuation
      (regexp   . "\\(\\s-*\\)\\\\$")
@@ -578,8 +578,13 @@ The possible settings for `align-region-separate' are:
      (justify  . t)
      (run-if   . ,(function
                   (lambda ()
-                    (eq '- current-prefix-arg))))))
-  "*An list describing all of the available alignment rules.
+                    (eq '- current-prefix-arg)))))
+
+    (css-declaration
+     (regexp . "^\\s-*\\w+:\\(\\s-*\\).*;")
+     (group . (1))
+     (modes . '(css-mode html-mode))))
+  "*A list describing all of the available alignment rules.
 The format is:
 
    ((TITLE
@@ -635,9 +640,9 @@ The following attributes are meaningful:
            containing alphabetic character, sometimes you may want
            the search to proceed case-insensitively (for languages
            that ignore case, such as pascal for example).  In that
-           case, set `case-fold' to nil, and the regular expression
-           search will ignore case.  If `regexp' is set to a
-           function, that function must handle the job of ignoring
+           case, set `case-fold' to a non-nil value, and the regular
+           expression search will ignore case.  If `regexp' is set to
+           function, that function must handle the job of ignoring
            case by itself.
 
 `tab-stop'  If the `tab-stop' attribute is set, and non-nil, the
@@ -777,7 +782,7 @@ The following attributes are meaningful:
      (regexp . "^\\s-*#\\s-*\\(if\\w*\\|endif\\)\\(.*\\)$")
      (group  . 2)
      (modes  . align-c++-modes)))
-  "*An list describing text that should be excluded from alignment.
+  "*A list describing text that should be excluded from alignment.
 See the documentation for `align-rules-list' for more info."
   :type align-exclude-rules-list-type
   :group 'align)
@@ -872,7 +877,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)))
@@ -932,10 +938,10 @@ region, call `align-regexp' and type in that regular expression."
     (if current-prefix-arg
        (list (read-string "Complex align using regexp: "
                           "\\(\\s-*\\)")
-             (string-to-int
+             (string-to-number
               (read-string
                "Parenthesis group to modify (justify if negative): " "1"))
-             (string-to-int
+             (string-to-number
               (read-string "Amount of spacing (or column if negative): "
                            (number-to-string align-default-spacing)))
              (y-or-n-p "Repeat throughout line? "))
@@ -1037,7 +1043,8 @@ to be colored."
 (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)
+  (let ((separate (or (if (and (symbolp align-region-separate)
+                              (boundp align-region-separate))
                          (symbol-value align-region-separate)
                        align-region-separate)
                      'entire))
@@ -1210,6 +1217,14 @@ have been aligned.  No changes will be made to the buffer."
              (cond ((< gocol 0) t)     ; don't do anything
                    ((= cur gocol) t)   ; don't need to
                    ((< cur gocol)      ; just add space
+                    ;; FIXME: It is stated above that "...the
+                    ;;        whitespace to be modified was already
+                    ;;        deleted by `align-region', all we have
+                    ;;        to do here is indent."  However, this
+                    ;;        doesn't seem to be true, so we first
+                    ;;        delete the whitespace to avoid tabs
+                    ;;        after spaces.
+                    (delete-horizontal-space t)
                     (indent-to gocol))
                    (t
                     ;; This code works around an oddity in the
@@ -1411,11 +1426,11 @@ aligner would have dealt with are."
                        ;; are, if it's a very large region being
                        ;; aligned
                        (if report
-                           (let ((name (symbol-name (car rule))))
-                             (if name
+                           (let ((symbol (car rule)))
+                             (if (and symbol (symbolp symbol))
                                  (message
                                   "Aligning `%s' (rule %d of %d) %d%%..."
-                                  rule-index rule-count
+                                  (symbol-name symbol) rule-index rule-count
                                   (/ (* (- (point) real-beg) 100)
                                      (- end-mark real-beg)))
                                (message
@@ -1586,4 +1601,5 @@ aligner would have dealt with are."
 
 (run-hooks 'align-load-hook)
 
+;;; arch-tag: ef79cccf-1db8-4888-a8a1-d7ce2d1532f7
 ;;; align.el ends here