aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2007-09-22 00:57:00 +0000
committerDan Nicolaescu2007-09-22 00:57:00 +0000
commit6dd697d9a5a0d749e26b0c371d0f96a47e1ed501 (patch)
tree11364c8b455f88ebdf23132ba2a7cb4af57aec2e
parentc7da3b7091aa317f54d8097fc1c4919cb2356193 (diff)
downloademacs-6dd697d9a5a0d749e26b0c371d0f96a47e1ed501.tar.gz
emacs-6dd697d9a5a0d749e26b0c371d0f96a47e1ed501.zip
(indent-for-tab-command): Indent the region if
transient-mark-mode and the region is active.
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/indent.el13
3 files changed, 18 insertions, 3 deletions
diff --git a/etc/NEWS b/etc/NEWS
index a154234f6fa..323425e9823 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -110,6 +110,9 @@ file or directory.
110 110
111* Editing Changes in Emacs 23.1 111* Editing Changes in Emacs 23.1
112 112
113** TAB now indents the region if the region is active and
114`transient-mark-mode' is turned on.
115
113** C-z now invokes `suspend-frame', C-x C-c now invokes 116** C-z now invokes `suspend-frame', C-x C-c now invokes
114`save-buffers-kill-terminal'. 117`save-buffers-kill-terminal'.
115 118
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 39c11d23041..858f9b39c18 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12007-09-22 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * indent.el (indent-for-tab-command): Indent the region if
4 transient-mark-mode and the region is active.
5
12007-09-21 Francesco Potort,Al(B <pot@gnu.org> 62007-09-21 Francesco Potort,Al(B <pot@gnu.org>
2 7
3 * progmodes/octave-inf.el (inferior-octave-mode): Use add-hook to 8 * progmodes/octave-inf.el (inferior-octave-mode): Use add-hook to
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."
78 (funcall indent-line-function))) 78 (funcall indent-line-function)))
79 79
80(defun indent-for-tab-command (&optional arg) 80(defun indent-for-tab-command (&optional arg)
81 "Indent line in proper way for current major mode or insert a tab. 81 "Indent line or region in proper way for current major mode or insert a tab.
82Depending on `tab-always-indent', either insert a tab or indent. 82Depending on `tab-always-indent', either insert a tab or indent.
83If initial point was within line's indentation, position after 83If initial point was within line's indentation, position after
84the indentation. Else stay at same point in text. 84the indentation. Else stay at same point in text.
85The function actually called to indent is determined by the value of 85If `transient-mark-mode' is turned on the region is active,
86indent the region.
87The function actually called to indent the line is determined by the value of
86`indent-line-function'." 88`indent-line-function'."
87 (interactive "P") 89 (interactive "P")
88 (cond 90 (cond
@@ -97,7 +99,12 @@ The function actually called to indent is determined by the value of
97 ;; indenting, so we can't pass them to indent-according-to-mode. 99 ;; indenting, so we can't pass them to indent-according-to-mode.
98 ((memq indent-line-function '(indent-relative indent-relative-maybe)) 100 ((memq indent-line-function '(indent-relative indent-relative-maybe))
99 (funcall indent-line-function)) 101 (funcall indent-line-function))
100 (t ;; The normal case. 102 ;; The region is active, indent it.
103 ((and transient-mark-mode mark-active
104 (not (eq (region-beginning) (region-end))))
105 (indent-region (region-beginning) (region-end)))
106 ;; Indent the line.
107 (t
101 (indent-according-to-mode)))) 108 (indent-according-to-mode))))
102 109
103(defun insert-tab (&optional arg) 110(defun insert-tab (&optional arg)