diff lisp/indent.el @ 91040:14c4a6aac623

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 866-879) - Merge multi-tty branch - Update from CVS - Merge from emacs--rel--22 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-257
author Miles Bader <miles@gnu.org>
date Thu, 11 Oct 2007 16:14:00 +0000
parents f55f9811f5d7 f4b3c97a692f
children 1251cabc40b7
line wrap: on
line diff
--- a/lisp/indent.el	Thu Oct 11 01:51:15 2007 +0000
+++ b/lisp/indent.el	Thu Oct 11 16:14:00 2007 +0000
@@ -78,14 +78,20 @@
     (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 `transient-mark-mode' is turned on the region is active,
+indent the region.
+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)
@@ -97,7 +103,8 @@
    ;; 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 the line.
+   (t
     (indent-according-to-mode))))
 
 (defun insert-tab (&optional arg)