diff options
| -rw-r--r-- | lisp/progmodes/c-mode.el | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lisp/progmodes/c-mode.el b/lisp/progmodes/c-mode.el index 114bec7d480..bbd077fd232 100644 --- a/lisp/progmodes/c-mode.el +++ b/lisp/progmodes/c-mode.el | |||
| @@ -630,13 +630,15 @@ Return the amount the indentation changed by." | |||
| 630 | (setq indent (save-excursion | 630 | (setq indent (save-excursion |
| 631 | (c-backward-to-start-of-if) | 631 | (c-backward-to-start-of-if) |
| 632 | (current-indentation)))) | 632 | (current-indentation)))) |
| 633 | ((looking-at "}[ \t]*else") | 633 | ((and (looking-at "}[ \t]*else\\b") |
| 634 | (not (looking-at "}[ \t]*else\\s_"))) | ||
| 634 | (setq indent (save-excursion | 635 | (setq indent (save-excursion |
| 635 | (forward-char) | 636 | (forward-char) |
| 636 | (backward-sexp) | 637 | (backward-sexp) |
| 637 | (c-backward-to-start-of-if) | 638 | (c-backward-to-start-of-if) |
| 638 | (current-indentation)))) | 639 | (current-indentation)))) |
| 639 | ((and (looking-at "while\\b") | 640 | ((and (looking-at "while\\b") |
| 641 | (not (looking-at "while\\s_")) | ||
| 640 | (save-excursion | 642 | (save-excursion |
| 641 | (c-backward-to-start-of-do))) | 643 | (c-backward-to-start-of-do))) |
| 642 | ;; This is a `while' that ends a do-while. | 644 | ;; This is a `while' that ends a do-while. |
| @@ -933,9 +935,11 @@ return the indentation of the text that would follow this star." | |||
| 933 | (case-fold-search nil)) | 935 | (case-fold-search nil)) |
| 934 | (while (and (not (bobp)) (not (zerop if-level))) | 936 | (while (and (not (bobp)) (not (zerop if-level))) |
| 935 | (backward-sexp 1) | 937 | (backward-sexp 1) |
| 936 | (cond ((looking-at "else\\b") | 938 | (cond ((and (looking-at "else\\b") |
| 939 | (not (looking-at "else\\s_"))) | ||
| 937 | (setq if-level (1+ if-level))) | 940 | (setq if-level (1+ if-level))) |
| 938 | ((looking-at "if\\b") | 941 | ((and (looking-at "if\\b") |
| 942 | (not (looking-at "if\\s_"))) | ||
| 939 | (setq if-level (1- if-level))) | 943 | (setq if-level (1- if-level))) |
| 940 | ((< (point) limit) | 944 | ((< (point) limit) |
| 941 | (setq if-level 0) | 945 | (setq if-level 0) |
| @@ -1189,9 +1193,11 @@ If within a string or comment, move by sentences instead of statements." | |||
| 1189 | ;; Find last non-comment character before this line | 1193 | ;; Find last non-comment character before this line |
| 1190 | (save-excursion | 1194 | (save-excursion |
| 1191 | (setq this-point (point)) | 1195 | (setq this-point (point)) |
| 1192 | (setq at-else (looking-at "else\\W")) | 1196 | (setq at-else (and (looking-at "else\\b") |
| 1197 | (not (looking-at "else\\s_")))) | ||
| 1193 | (setq at-brace (= (following-char) ?{)) | 1198 | (setq at-brace (= (following-char) ?{)) |
| 1194 | (setq at-while (looking-at "while\\b")) | 1199 | (setq at-while (and (looking-at "while\\b") |
| 1200 | (not (looking-at "while\\s_")))) | ||
| 1195 | (if (= (following-char) ?}) | 1201 | (if (= (following-char) ?}) |
| 1196 | (setq this-indent (car indent-stack)) | 1202 | (setq this-indent (car indent-stack)) |
| 1197 | (c-backward-to-noncomment opoint) | 1203 | (c-backward-to-noncomment opoint) |