diff options
| author | Dan Nicolaescu | 2007-09-22 00:57:00 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2007-09-22 00:57:00 +0000 |
| commit | 6dd697d9a5a0d749e26b0c371d0f96a47e1ed501 (patch) | |
| tree | 11364c8b455f88ebdf23132ba2a7cb4af57aec2e /lisp | |
| parent | c7da3b7091aa317f54d8097fc1c4919cb2356193 (diff) | |
| download | emacs-6dd697d9a5a0d749e26b0c371d0f96a47e1ed501.tar.gz emacs-6dd697d9a5a0d749e26b0c371d0f96a47e1ed501.zip | |
(indent-for-tab-command): Indent the region if
transient-mark-mode and the region is active.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/indent.el | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 39c11d23041..858f9b39c18 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2007-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 | |||
| 1 | 2007-09-21 Francesco Potort,Al(B <pot@gnu.org> | 6 | 2007-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. |
| 82 | Depending on `tab-always-indent', either insert a tab or indent. | 82 | Depending on `tab-always-indent', either insert a tab or indent. |
| 83 | If initial point was within line's indentation, position after | 83 | If initial point was within line's indentation, position after |
| 84 | the indentation. Else stay at same point in text. | 84 | the indentation. Else stay at same point in text. |
| 85 | The function actually called to indent is determined by the value of | 85 | If `transient-mark-mode' is turned on the region is active, |
| 86 | indent the region. | ||
| 87 | The 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) |