diff options
| author | Richard M. Stallman | 1994-02-07 00:55:58 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-02-07 00:55:58 +0000 |
| commit | f1ff6645440865dcbf65689b399d9d88d107d4e8 (patch) | |
| tree | b60cf6bcdbfafe372e5ba83a22a997784ada5d54 | |
| parent | 8052715a1f50bd30c980a6a6f003546259b58613 (diff) | |
| download | emacs-f1ff6645440865dcbf65689b399d9d88d107d4e8.tar.gz emacs-f1ff6645440865dcbf65689b399d9d88d107d4e8.zip | |
(indent-c-exp): If line starts with }, ignore what
the previous line ends with.
| -rw-r--r-- | lisp/progmodes/c-mode.el | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/lisp/progmodes/c-mode.el b/lisp/progmodes/c-mode.el index 47f39901dc2..e057a4a4ca4 100644 --- a/lisp/progmodes/c-mode.el +++ b/lisp/progmodes/c-mode.el | |||
| @@ -1161,27 +1161,29 @@ If within a string or comment, move by sentences instead of statements." | |||
| 1161 | (setq at-else (looking-at "else\\W")) | 1161 | (setq at-else (looking-at "else\\W")) |
| 1162 | (setq at-brace (= (following-char) ?{)) | 1162 | (setq at-brace (= (following-char) ?{)) |
| 1163 | (setq at-while (looking-at "while\\b")) | 1163 | (setq at-while (looking-at "while\\b")) |
| 1164 | (c-backward-to-noncomment opoint) | 1164 | (if (= (following-char) ?}) |
| 1165 | (if (not (memq (preceding-char) '(nil ?\, ?\; ?} ?: ?{))) | 1165 | (setq this-indent (car indent-stack)) |
| 1166 | ;; Preceding line did not end in comma or semi; | 1166 | (c-backward-to-noncomment opoint) |
| 1167 | ;; indent this line c-continued-statement-offset | 1167 | (if (not (memq (preceding-char) '(nil ?\, ?\; ?} ?: ?{))) |
| 1168 | ;; more than previous. | 1168 | ;; Preceding line did not end in comma or semi; |
| 1169 | (progn | 1169 | ;; indent this line c-continued-statement-offset |
| 1170 | (c-backward-to-start-of-continued-exp (car contain-stack)) | 1170 | ;; more than previous. |
| 1171 | (setq this-indent | 1171 | (progn |
| 1172 | (+ c-continued-statement-offset (current-column) | 1172 | (c-backward-to-start-of-continued-exp (car contain-stack)) |
| 1173 | (if at-brace c-continued-brace-offset 0)))) | 1173 | (setq this-indent |
| 1174 | ;; Preceding line ended in comma or semi; | 1174 | (+ c-continued-statement-offset (current-column) |
| 1175 | ;; use the standard indent for this level. | 1175 | (if at-brace c-continued-brace-offset 0)))) |
| 1176 | (cond (at-else (progn (c-backward-to-start-of-if opoint) | 1176 | ;; Preceding line ended in comma or semi; |
| 1177 | (setq this-indent | 1177 | ;; use the standard indent for this level. |
| 1178 | (current-indentation)))) | 1178 | (cond (at-else (progn (c-backward-to-start-of-if opoint) |
| 1179 | ((and at-while (c-backward-to-start-of-do opoint)) | 1179 | (setq this-indent |
| 1180 | (setq this-indent (current-indentation))) | 1180 | (current-indentation)))) |
| 1181 | ((eq (preceding-char) ?\,) | 1181 | ((and at-while (c-backward-to-start-of-do opoint)) |
| 1182 | (goto-char this-point) | 1182 | (setq this-indent (current-indentation))) |
| 1183 | (setq this-indent (calculate-c-indent))) | 1183 | ((eq (preceding-char) ?\,) |
| 1184 | (t (setq this-indent (car indent-stack))))))) | 1184 | (goto-char this-point) |
| 1185 | (setq this-indent (calculate-c-indent))) | ||
| 1186 | (t (setq this-indent (car indent-stack)))))))) | ||
| 1185 | ;; Just started a new nesting level. | 1187 | ;; Just started a new nesting level. |
| 1186 | ;; Compute the standard indent for this level. | 1188 | ;; Compute the standard indent for this level. |
| 1187 | (let ((val (calculate-c-indent | 1189 | (let ((val (calculate-c-indent |