# HG changeset patch # User Dan Nicolaescu # Date 1190422620 0 # Node ID d8b9b78eb16c5ea68fc68668b035492f65f83f58 # Parent c104419f915c863887327537373b4fc78ca954d3 (indent-for-tab-command): Indent the region if transient-mark-mode and the region is active. diff -r c104419f915c -r d8b9b78eb16c etc/NEWS --- a/etc/NEWS Sat Sep 22 00:09:45 2007 +0000 +++ b/etc/NEWS Sat Sep 22 00:57:00 2007 +0000 @@ -110,6 +110,9 @@ * 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'. diff -r c104419f915c -r d8b9b78eb16c lisp/ChangeLog --- a/lisp/ChangeLog Sat Sep 22 00:09:45 2007 +0000 +++ b/lisp/ChangeLog Sat Sep 22 00:57:00 2007 +0000 @@ -1,3 +1,8 @@ +2007-09-22 Dan Nicolaescu + + * indent.el (indent-for-tab-command): Indent the region if + transient-mark-mode and the region is active. + 2007-09-21 Francesco Potort,Al(B * progmodes/octave-inf.el (inferior-octave-mode): Use add-hook to diff -r c104419f915c -r d8b9b78eb16c lisp/indent.el --- a/lisp/indent.el Sat Sep 22 00:09:45 2007 +0000 +++ b/lisp/indent.el Sat Sep 22 00:57:00 2007 +0000 @@ -78,11 +78,13 @@ (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 @@ ;; 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)