aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2011-11-29 23:55:54 +0800
committerChong Yidong2011-11-29 23:55:54 +0800
commite70b5064d77602ba43cd31216ca8f3eb9a4c2c42 (patch)
treeb1979b58986f343ff5fd7f0d7d801b1cec0e2ec0
parentf3af92b794bcce576fb0acad47b41f677a2b41dc (diff)
downloademacs-e70b5064d77602ba43cd31216ca8f3eb9a4c2c42.tar.gz
emacs-e70b5064d77602ba43cd31216ca8f3eb9a4c2c42.zip
Update doc for behavior of TAB in Text based modes.
* lisp/indent.el (indent-for-tab-command, indent-according-to-mode): Doc fix. (indent-region): Doc fix. Switch nested ifs to equivalent cond.
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/indent.el85
3 files changed, 59 insertions, 39 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 4e329ea35fc..fe481c4ed8f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -551,6 +551,13 @@ at high rate, e.g. if you lean on some key, because stopping redisplay
551in the middle (when this variable is nil) forces more expensive 551in the middle (when this variable is nil) forces more expensive
552updates later on, and Emacs appears to be unable to keep up. 552updates later on, and Emacs appears to be unable to keep up.
553 553
554+++
555** The behavior of <TAB> for active regions in Text mode has changed.
556In Text and related modes, typing <TAB> (`indent-for-tab-command')
557when the region is active causes Emacs to indent all the lines in the
558region, aligning them with the line previous to the first line in the
559region (or with the left margin if there is no previous line).
560
554 561
555* Changes in Specialized Modes and Packages in Emacs 24.1 562* Changes in Specialized Modes and Packages in Emacs 24.1
556 563
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 37c7271b2f1..b25374d1eb0 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12011-11-29 Chong Yidong <cyd@gnu.org>
2
3 * indent.el (indent-for-tab-command, indent-according-to-mode):
4 Doc fix.
5 (indent-region): Doc fix. Switch nested ifs to equivalent cond.
6
12011-11-29 Michael Albinus <michael.albinus@gmx.de> 72011-11-29 Michael Albinus <michael.albinus@gmx.de>
2 8
3 * vc/diff-mode.el (diff-find-file-name): Make `read-file-name' 9 * vc/diff-mode.el (diff-find-file-name): Make `read-file-name'
diff --git a/lisp/indent.el b/lisp/indent.el
index 93218032700..f5850de8b8f 100644
--- a/lisp/indent.el
+++ b/lisp/indent.el
@@ -63,9 +63,11 @@ e.g., `c-tab-always-indent', and do not respect this variable."
63 63
64(defun indent-according-to-mode () 64(defun indent-according-to-mode ()
65 "Indent line in proper way for current major mode. 65 "Indent line in proper way for current major mode.
66The buffer-local variable `indent-line-function' determines how to do this, 66Normally, this is done by calling the function specified by the
67but the functions `indent-relative' and `indent-relative-maybe' are 67variable `indent-line-function'. However, if the value of that
68special; we don't actually use them here." 68variable is `indent-relative' or `indent-relative-maybe', handle
69it specially (since those functions are used for tabbing); in
70that case, indent by aligning to the previous non-blank line."
69 (interactive) 71 (interactive)
70 (syntax-propertize (line-end-position)) 72 (syntax-propertize (line-end-position))
71 (if (memq indent-line-function 73 (if (memq indent-line-function
@@ -84,22 +86,25 @@ special; we don't actually use them here."
84 (funcall indent-line-function))) 86 (funcall indent-line-function)))
85 87
86(defun indent-for-tab-command (&optional arg) 88(defun indent-for-tab-command (&optional arg)
87 "Indent line or region in proper way for current major mode or insert a tab. 89 "Indent the current line or region, or insert a tab, as appropriate.
88Depending on `tab-always-indent', either insert a tab or indent. 90This function either inserts a tab, or indents the current line,
89 91or performs symbol completion, depending on `tab-always-indent'.
90In most major modes, if point was in the current line's indentation, 92The function called to actually indent the line or insert a tab
91it is moved to the first non-whitespace character after indenting; 93is given by the variable `indent-line-function'.
92otherwise it stays at the same position in the text. 94
93 95If a prefix argument is given, after this function indents the
94If a prefix argument is given, also rigidly indent the entire 96current line or inserts a tab, it also rigidly indents the entire
95balanced expression which starts at the beginning of the current 97balanced expression which starts at the beginning of the current
96line to reflect the current line's change in indentation. 98line, to reflect the current line's indentation.
97 99
98If `transient-mark-mode' is turned on and the region is active, 100In most major modes, if point was in the current line's
99indent the region (in this case, any prefix argument is ignored). 101indentation, it is moved to the first non-whitespace character
102after indenting; otherwise it stays at the same position relative
103to the text.
100 104
101The function actually called to indent the line is determined by the value of 105If `transient-mark-mode' is turned on and the region is active,
102`indent-line-function'." 106this function instead calls `indent-region'. In this case, any
107prefix argument is ignored."
103 (interactive "P") 108 (interactive "P")
104 (cond 109 (cond
105 ;; The region is active, indent it. 110 ;; The region is active, indent it.
@@ -393,34 +398,14 @@ indents all the lines with it:
393 with it. 398 with it.
394 2) If `indent-region-function' is non-nil, call that function 399 2) If `indent-region-function' is non-nil, call that function
395 to indent the region. 400 to indent the region.
396 3) Indent each line as specified by the variable `indent-line-function'. 401 3) Indent each line via `indent-according-to-mode'.
397 402
398Called from a program, START and END specify the region to indent. 403Called from a program, START and END specify the region to indent.
399If the third argument COLUMN is an integer, it specifies the 404If the third argument COLUMN is an integer, it specifies the
400column to indent to; if it is nil, use one of the three methods above." 405column to indent to; if it is nil, use one of the three methods above."
401 (interactive "r\nP") 406 (interactive "r\nP")
402 (if (null column) 407 (cond
403 (if fill-prefix 408 (column
404 (save-excursion
405 (goto-char end)
406 (setq end (point-marker))
407 (goto-char start)
408 (let ((regexp (regexp-quote fill-prefix)))
409 (while (< (point) end)
410 (or (looking-at regexp)
411 (and (bolp) (eolp))
412 (insert fill-prefix))
413 (forward-line 1))))
414 (if indent-region-function
415 (funcall indent-region-function start end)
416 (save-excursion
417 (setq end (copy-marker end))
418 (goto-char start)
419 (while (< (point) end)
420 (or (and (bolp) (eolp))
421 (indent-according-to-mode))
422 (forward-line 1))
423 (move-marker end nil))))
424 (setq column (prefix-numeric-value column)) 409 (setq column (prefix-numeric-value column))
425 (save-excursion 410 (save-excursion
426 (goto-char end) 411 (goto-char end)
@@ -433,6 +418,28 @@ column to indent to; if it is nil, use one of the three methods above."
433 (indent-to column 0)) 418 (indent-to column 0))
434 (forward-line 1)) 419 (forward-line 1))
435 (move-marker end nil))) 420 (move-marker end nil)))
421 (fill-prefix
422 (save-excursion
423 (goto-char end)
424 (setq end (point-marker))
425 (goto-char start)
426 (let ((regexp (regexp-quote fill-prefix)))
427 (while (< (point) end)
428 (or (looking-at regexp)
429 (and (bolp) (eolp))
430 (insert fill-prefix))
431 (forward-line 1)))))
432 (indent-region-function
433 (funcall indent-region-function start end))
434 (t
435 (save-excursion
436 (setq end (copy-marker end))
437 (goto-char start)
438 (while (< (point) end)
439 (or (and (bolp) (eolp))
440 (indent-according-to-mode))
441 (forward-line 1))
442 (move-marker end nil))))
436 ;; In most cases, reindenting modifies the buffer, but it may also 443 ;; In most cases, reindenting modifies the buffer, but it may also
437 ;; leave it unmodified, in which case we have to deactivate the mark 444 ;; leave it unmodified, in which case we have to deactivate the mark
438 ;; by hand. 445 ;; by hand.