49 |
"*Controls the operation of the TAB key. |
"*Controls the operation of the TAB key. |
50 |
If t, hitting TAB always just indents the current line. |
If t, hitting TAB always just indents the current line. |
51 |
If nil, hitting TAB indents the current line if point is at the left margin |
If nil, hitting TAB indents the current line if point is at the left margin |
52 |
or in the line's indentation, otherwise it insert a `real' tab character." |
or in the line's indentation, otherwise it insert a \"real\" tab character." |
53 |
:group 'indent |
:group 'indent |
54 |
:type '(choice (const nil) (const t) (const always))) |
:type '(choice (const nil) (const t) (const always))) |
55 |
|
|
56 |
(defun indent-according-to-mode () |
(defun indent-according-to-mode () |
57 |
"Indent line in proper way for current major mode." |
"Indent line in proper way for current major mode. |
58 |
|
The buffer-local variable `indent-line-function' determines how to do this, |
59 |
|
but the functions `indent-relative' and `indent-relative-maybe' are |
60 |
|
special; we don't actually use them here." |
61 |
(interactive) |
(interactive) |
62 |
(if (memq indent-line-function |
(if (memq indent-line-function |
63 |
'(indent-relative indent-relative-maybe)) |
'(indent-relative indent-relative-maybe)) |
87 |
;; so we force it to always insert a tab here. |
;; so we force it to always insert a tab here. |
88 |
(eq indent-line-function 'indent-to-left-margin) |
(eq indent-line-function 'indent-to-left-margin) |
89 |
(and (not tab-always-indent) |
(and (not tab-always-indent) |
90 |
(> (current-column) (current-indentation)))) |
(or (> (current-column) (current-indentation)) |
91 |
|
(eq this-command last-command)))) |
92 |
(insert-tab arg)) |
(insert-tab arg)) |
93 |
;; Those functions are meant specifically for tabbing and not for |
;; Those functions are meant specifically for tabbing and not for |
94 |
;; indenting, so we can't pass them to indent-according-to-mode. |
;; indenting, so we can't pass them to indent-according-to-mode. |
173 |
((and force (< cc lm)) |
((and force (< cc lm)) |
174 |
(indent-to-left-margin))))) |
(indent-to-left-margin))))) |
175 |
|
|
176 |
;; This is the default indent-line-function, |
;; This used to be the default indent-line-function, |
177 |
;; used in Fundamental Mode, Text Mode, etc. |
;; used in Fundamental Mode, Text Mode, etc. |
178 |
(defun indent-to-left-margin () |
(defun indent-to-left-margin () |
179 |
"Indent current line to the column given by `current-left-margin'." |
"Indent current line to the column given by `current-left-margin'." |
304 |
With optional argument, move forward N-1 lines first. |
With optional argument, move forward N-1 lines first. |
305 |
From the beginning of the line, moves past the left-margin indentation, the |
From the beginning of the line, moves past the left-margin indentation, the |
306 |
fill-prefix, and any indentation used for centering or right-justifying the |
fill-prefix, and any indentation used for centering or right-justifying the |
307 |
line, but does not move past any whitespace that was explicitly inserted |
line, but does not move past any whitespace that was explicitly inserted |
308 |
\(such as a tab used to indent the first line of a paragraph)." |
\(such as a tab used to indent the first line of a paragraph)." |
309 |
(interactive "p") |
(interactive "p") |
310 |
(beginning-of-line n) |
(beginning-of-line n) |
311 |
(skip-chars-forward " \t") |
(skip-chars-forward " \t") |
312 |
;; Skip over fill-prefix. |
;; Skip over fill-prefix. |
313 |
(if (and fill-prefix |
(if (and fill-prefix |
314 |
(not (string-equal fill-prefix ""))) |
(not (string-equal fill-prefix ""))) |
315 |
(if (equal fill-prefix |
(if (equal fill-prefix |
316 |
(buffer-substring |
(buffer-substring |
317 |
(point) (min (point-max) (+ (length fill-prefix) (point))))) |
(point) (min (point-max) (+ (length fill-prefix) (point))))) |
318 |
(forward-char (length fill-prefix))) |
(forward-char (length fill-prefix))) |
319 |
(if (and adaptive-fill-mode adaptive-fill-regexp |
(if (and adaptive-fill-mode adaptive-fill-regexp |
329 |
|
|
330 |
(defun indent-region (start end &optional column) |
(defun indent-region (start end &optional column) |
331 |
"Indent each nonblank line in the region. |
"Indent each nonblank line in the region. |
332 |
With no prefix argument, indent each line using `indent-according-to-mode', |
A numeric prefix argument specifies a column: indent each line to that column. |
333 |
or use `indent-region-function' to do the whole region if that's non-nil. |
|
334 |
If there is a fill prefix, make each line start with the fill prefix. |
With no prefix argument, the command chooses one of these methods and |
335 |
With argument COLUMN, indent each line to that column. |
indents all the lines with it: |
336 |
|
|
337 |
When you call this from a program, START and END specify |
1) If `fill-prefix' is non-nil, insert `fill-prefix' at the |
338 |
the region to indent, and COLUMN specifies the indentation column. |
beginning of each line in the region that does not already begin |
339 |
If COLUMN is nil, then indent each line according to the mode." |
with it. |
340 |
|
2) If `indent-region-function' is non-nil, call that function |
341 |
|
to indent the region. |
342 |
|
3) Indent each line as specified by the variable `indent-line-function'. |
343 |
|
|
344 |
|
Called from a program, START and END specify the region to indent. |
345 |
|
If the third argument COLUMN is an integer, it specifies the |
346 |
|
column to indent to; if it is nil, use one of the three methods above." |
347 |
(interactive "r\nP") |
(interactive "r\nP") |
348 |
(if (null column) |
(if (null column) |
349 |
(if fill-prefix |
(if fill-prefix |