Remove multiple entries about re-generating configure.
[bpt/emacs.git] / lisp / indent.el
index b580e3a..c46bbd6 100644 (file)
@@ -1,7 +1,7 @@
 ;;; indent.el --- indentation commands for Emacs
 
 ;; Copyright (C) 1985, 1995, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007 Free Software Foundation, Inc.
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 
@@ -78,14 +78,26 @@ special; we don't actually use them here."
     (funcall indent-line-function)))
 
 (defun indent-for-tab-command (&optional arg)
-  "Indent line in proper way for current major mode or insert a tab.
+  "Indent line or region in proper way for current major mode or insert a tab.
 Depending on `tab-always-indent', either insert a tab or indent.
 If initial point was within line's indentation, position after
 the indentation.  Else stay at same point in text.
-The function actually called to indent is determined by the value of
+
+If a prefix argument is given, also rigidly indent the entire
+balanced expression which starts at the beginning the current
+line to reflect the current line's change in indentation.
+
+If `transient-mark-mode' is turned on and the region is active,
+indent the region (in this case, any prefix argument is ignored).
+
+The function actually called to indent the line is determined by the value of
 `indent-line-function'."
   (interactive "P")
   (cond
+   ;; The region is active, indent it.
+   ((and transient-mark-mode mark-active
+        (not (eq (region-beginning) (region-end))))
+    (indent-region (region-beginning) (region-end)))
    ((or ;; indent-to-left-margin is only meant for indenting,
        ;; so we force it to always insert a tab here.
        (eq indent-line-function 'indent-to-left-margin)
@@ -93,12 +105,27 @@ The function actually called to indent is determined by the value of
             (or (> (current-column) (current-indentation))
                 (eq this-command last-command))))
     (insert-tab arg))
-   ;; Those functions are meant specifically for tabbing and not for
-   ;; indenting, so we can't pass them to indent-according-to-mode.
-   ((memq indent-line-function '(indent-relative indent-relative-maybe))
-    (funcall indent-line-function))
-   (t ;; The normal case.
-    (indent-according-to-mode))))
+   (t
+    (let ((end-marker
+          (and arg
+               (save-excursion
+                 (forward-line 0) (forward-sexp) (point-marker))))
+         (old-indent
+          (current-indentation)))
+
+      ;; Indent the line.
+      (funcall indent-line-function)
+
+      ;; If a prefix argument was given, rigidly indent the following
+      ;; sexp to match the change in the current line's indentation.
+      ;;
+      (when arg
+       (let ((indentation-change (- (current-indentation) old-indent)))
+         (unless (zerop indentation-change)
+           (save-excursion
+             (forward-line 1)
+             (when (< (point) end-marker)
+               (indent-rigidly (point) end-marker indentation-change))))))))))
 
 (defun insert-tab (&optional arg)
   (let ((count (prefix-numeric-value arg)))
@@ -184,7 +211,12 @@ interactively or with optional argument FORCE, it will be fixed."
 ;; used in Fundamental Mode, Text Mode, etc.
 (defun indent-to-left-margin ()
   "Indent current line to the column given by `current-left-margin'."
-  (indent-line-to (current-left-margin)))
+  (save-excursion (indent-line-to (current-left-margin)))
+  ;; If we are within the indentation, move past it.
+  (when (save-excursion
+         (skip-chars-backward " \t")
+         (bolp))
+    (skip-chars-forward " \t")))
 
 (defun delete-to-left-margin (&optional from to)
   "Remove left margin indentation from a region.
@@ -442,6 +474,7 @@ See also `indent-relative-maybe'."
 This should be a list of integers, ordered from smallest to largest."
   :group 'indent
   :type '(repeat integer))
+(put 'tab-stop-list 'safe-local-variable 'listp)
 
 (defvar edit-tab-stops-map
   (let ((map (make-sparse-keymap)))