]> git.eshelyaron.com Git - emacs.git/commitdiff
(indent-for-tab-command): Indent the region if
authorDan Nicolaescu <dann@ics.uci.edu>
Sat, 22 Sep 2007 00:57:00 +0000 (00:57 +0000)
committerDan Nicolaescu <dann@ics.uci.edu>
Sat, 22 Sep 2007 00:57:00 +0000 (00:57 +0000)
transient-mark-mode and the region is active.

etc/NEWS
lisp/ChangeLog
lisp/indent.el

index a154234f6faaeb9f5c6cfa4c03ebe76dfc54862f..323425e9823e8719d73aa378a695e8738b1c9359 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -110,6 +110,9 @@ file or directory.
 \f
 * Editing Changes in Emacs 23.1
 
+** TAB now indents the region if the region is active and
+`transient-mark-mode' is turned on.
+
 ** C-z now invokes `suspend-frame', C-x C-c now invokes
 `save-buffers-kill-terminal'.
 
index 39c11d23041af7668b6b4ff51535695ade2a592f..858f9b39c18383e3e5f9971a5dc5a414a17556fa 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-22  Dan Nicolaescu  <dann@ics.uci.edu>
+
+       * indent.el (indent-for-tab-command): Indent the region if
+       transient-mark-mode and the region is active.
+
 2007-09-21  Francesco Potort\e,Al\e(B  <pot@gnu.org>
 
        * progmodes/octave-inf.el (inferior-octave-mode): Use add-hook to
index b580e3aa3ce54d2cdc61e3c05ad0ab08a3e8f0ca..2108b340f1bd24bf73ca2d011cd8f85263557cfa 100644 (file)
@@ -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)