summaryrefslogtreecommitdiff
path: root/lisp/indent.el
diff options
context:
space:
mode:
authorDan Nicolaescu <dann@ics.uci.edu>2007-09-22 00:57:00 +0000
committerDan Nicolaescu <dann@ics.uci.edu>2007-09-22 00:57:00 +0000
commit6dd697d9a5a0d749e26b0c371d0f96a47e1ed501 (patch)
tree11364c8b455f88ebdf23132ba2a7cb4af57aec2e /lisp/indent.el
parentc7da3b7091aa317f54d8097fc1c4919cb2356193 (diff)
(indent-for-tab-command): Indent the region if
transient-mark-mode and the region is active.
Diffstat (limited to 'lisp/indent.el')
-rw-r--r--lisp/indent.el13
1 files changed, 10 insertions, 3 deletions
diff --git a/lisp/indent.el b/lisp/indent.el
index b580e3aa3ce..2108b340f1b 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -78,11 +78,13 @@ 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 `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
@@ -97,7 +99,12 @@ The function actually called to indent is determined by the value of
;; 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.
+ ;; The region is active, indent it.
+ ((and transient-mark-mode mark-active
+ (not (eq (region-beginning) (region-end))))
+ (indent-region (region-beginning) (region-end)))
+ ;; Indent the line.
+ (t
(indent-according-to-mode))))
(defun insert-tab (&optional arg)