diff options
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/indent.el | 38 |
2 files changed, 40 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0c80dccccf1..af3dc434448 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2007-12-25 Miles Bader <miles@gnu.org> | ||
| 2 | |||
| 3 | * indent.el (indent-for-tab-command): Rigidly indent the following | ||
| 4 | sexp along with the current line when a prefix arg is given in the | ||
| 5 | non-active-region case. Specify raw prefix in interactive spec. | ||
| 6 | Simplify main indentation logic to get rid of the conditional call | ||
| 7 | to `indent-according-to-mode' (it just ended up calling | ||
| 8 | `indent-line-function' in all cases anyway, which can be done more | ||
| 9 | simply here). Remove unnecessary test of ARG in active region | ||
| 10 | case. | ||
| 11 | |||
| 1 | 2007-12-25 Richard Stallman <rms@gnu.org> | 12 | 2007-12-25 Richard Stallman <rms@gnu.org> |
| 2 | 13 | ||
| 3 | * simple.el (select-active-regions): New option. | 14 | * simple.el (select-active-regions): New option. |
diff --git a/lisp/indent.el b/lisp/indent.el index 96f65dcf778..17ebe3b5567 100644 --- a/lisp/indent.el +++ b/lisp/indent.el | |||
| @@ -82,14 +82,20 @@ special; we don't actually use them here." | |||
| 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 | |||
| 86 | If a prefix argument is given, also rigidly indent the entire | ||
| 87 | balanced expression which starts at the beginning the current | ||
| 88 | line to reflect the current line's change in indentation. | ||
| 89 | |||
| 85 | If `transient-mark-mode' is turned on and the region is active, | 90 | If `transient-mark-mode' is turned on and the region is active, |
| 86 | indent the region. | 91 | indent the region (in this case, any prefix argument is ignored). |
| 92 | |||
| 87 | The function actually called to indent the line is determined by the value of | 93 | The function actually called to indent the line is determined by the value of |
| 88 | `indent-line-function'." | 94 | `indent-line-function'." |
| 89 | (interactive "p") | 95 | (interactive "P") |
| 90 | (cond | 96 | (cond |
| 91 | ;; The region is active, indent it. | 97 | ;; The region is active, indent it. |
| 92 | ((and arg transient-mark-mode mark-active | 98 | ((and transient-mark-mode mark-active |
| 93 | (not (eq (region-beginning) (region-end)))) | 99 | (not (eq (region-beginning) (region-end)))) |
| 94 | (indent-region (region-beginning) (region-end))) | 100 | (indent-region (region-beginning) (region-end))) |
| 95 | ((or ;; indent-to-left-margin is only meant for indenting, | 101 | ((or ;; indent-to-left-margin is only meant for indenting, |
| @@ -99,13 +105,27 @@ The function actually called to indent the line is determined by the value of | |||
| 99 | (or (> (current-column) (current-indentation)) | 105 | (or (> (current-column) (current-indentation)) |
| 100 | (eq this-command last-command)))) | 106 | (eq this-command last-command)))) |
| 101 | (insert-tab arg)) | 107 | (insert-tab arg)) |
| 102 | ;; Those functions are meant specifically for tabbing and not for | ||
| 103 | ;; indenting, so we can't pass them to indent-according-to-mode. | ||
| 104 | ((memq indent-line-function '(indent-relative indent-relative-maybe)) | ||
| 105 | (funcall indent-line-function)) | ||
| 106 | ;; Indent the line. | ||
| 107 | (t | 108 | (t |
| 108 | (indent-according-to-mode)))) | 109 | (let ((end-marker |
| 110 | (and arg | ||
| 111 | (save-excursion | ||
| 112 | (forward-line 0) (forward-sexp) (point-marker)))) | ||
| 113 | (old-indent | ||
| 114 | (current-indentation))) | ||
| 115 | |||
| 116 | ;; Indent the line. | ||
| 117 | (funcall indent-line-function) | ||
| 118 | |||
| 119 | ;; If a prefix argument was given, rigidly indent the following | ||
| 120 | ;; sexp to match the change in the current line's indentation. | ||
| 121 | ;; | ||
| 122 | (when arg | ||
| 123 | (let ((indentation-change (- (current-indentation) old-indent))) | ||
| 124 | (unless (zerop indentation-change) | ||
| 125 | (save-excursion | ||
| 126 | (forward-line 1) | ||
| 127 | (when (< (point) end-marker) | ||
| 128 | (indent-rigidly (point) end-marker indentation-change)))))))))) | ||
| 109 | 129 | ||
| 110 | (defun insert-tab (&optional arg) | 130 | (defun insert-tab (&optional arg) |
| 111 | (let ((count (prefix-numeric-value arg))) | 131 | (let ((count (prefix-numeric-value arg))) |