diff options
| author | Alan Mackenzie | 2018-12-07 17:38:03 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2018-12-07 17:39:38 +0000 |
| commit | f6a69957d654f0d0d870209da303b4e9360d577e (patch) | |
| tree | 940a89be49699d8cc507714c7daa2bd00847051d | |
| parent | 294b2c2bb71f1f7e7024a854d4a4ae43785d9594 (diff) | |
| download | emacs-f6a69957d654f0d0d870209da303b4e9360d577e.tar.gz emacs-f6a69957d654f0d0d870209da303b4e9360d577e.zip | |
CC Mode: Compensate for backward-sexp ignoring trailing commas after {...}
This fixes bug #32808.
* lisp/progmodes/cc-engine.el (c-beginning-of-statement-1): New variable
comma-delimited, set when we're about to scan backward over a comma. Do not
reckon a brace block as bounding a statement when it is followed or preceded
by a comma (except when argument comma-delim is non-nil).
(c-guess-basic-syntax, CASE 9C): Call c-beginning-of-statement-1 with argument
comma-delim changed to non-nil.
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 9cd2174b665..376d0bb3d3a 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -1080,12 +1080,15 @@ comment at the start of cc-engine.el for more info." | |||
| 1080 | (let ((before-sws-pos (point)) | 1080 | (let ((before-sws-pos (point)) |
| 1081 | ;; The end position of the area to search for statement | 1081 | ;; The end position of the area to search for statement |
| 1082 | ;; barriers in this round. | 1082 | ;; barriers in this round. |
| 1083 | (maybe-after-boundary-pos pos)) | 1083 | (maybe-after-boundary-pos pos) |
| 1084 | comma-delimited) | ||
| 1084 | 1085 | ||
| 1085 | ;; Go back over exactly one logical sexp, taking proper | 1086 | ;; Go back over exactly one logical sexp, taking proper |
| 1086 | ;; account of macros and escaped EOLs. | 1087 | ;; account of macros and escaped EOLs. |
| 1087 | (while | 1088 | (while |
| 1088 | (progn | 1089 | (progn |
| 1090 | (setq comma-delimited (and (not comma-delim) | ||
| 1091 | (eq (char-before) ?\,))) | ||
| 1089 | (unless (c-safe (c-backward-sexp) t) | 1092 | (unless (c-safe (c-backward-sexp) t) |
| 1090 | ;; Give up if we hit an unbalanced block. Since the | 1093 | ;; Give up if we hit an unbalanced block. Since the |
| 1091 | ;; stack won't be empty the code below will report a | 1094 | ;; stack won't be empty the code below will report a |
| @@ -1121,6 +1124,7 @@ comment at the start of cc-engine.el for more info." | |||
| 1121 | ;; Just gone back over a brace block? | 1124 | ;; Just gone back over a brace block? |
| 1122 | ((and | 1125 | ((and |
| 1123 | (eq (char-after) ?{) | 1126 | (eq (char-after) ?{) |
| 1127 | (not comma-delimited) | ||
| 1124 | (not (c-looking-at-inexpr-block lim nil t)) | 1128 | (not (c-looking-at-inexpr-block lim nil t)) |
| 1125 | (save-excursion | 1129 | (save-excursion |
| 1126 | (c-backward-token-2 1 t nil) | 1130 | (c-backward-token-2 1 t nil) |
| @@ -1132,8 +1136,11 @@ comment at the start of cc-engine.el for more info." | |||
| 1132 | (if (and (looking-at c-symbol-start) | 1136 | (if (and (looking-at c-symbol-start) |
| 1133 | (not (looking-at c-keywords-regexp))) | 1137 | (not (looking-at c-keywords-regexp))) |
| 1134 | (c-backward-token-2 1 t nil)) | 1138 | (c-backward-token-2 1 t nil)) |
| 1135 | (not (looking-at | 1139 | (and |
| 1136 | c-opt-block-decls-with-vars-key))))) | 1140 | (not (looking-at |
| 1141 | c-opt-block-decls-with-vars-key)) | ||
| 1142 | (or comma-delim | ||
| 1143 | (not (eq (char-after) ?\,))))))) | ||
| 1137 | (save-excursion | 1144 | (save-excursion |
| 1138 | (c-forward-sexp) (point))) | 1145 | (c-forward-sexp) (point))) |
| 1139 | ;; Just gone back over some paren block? | 1146 | ;; Just gone back over some paren block? |
| @@ -12711,7 +12718,7 @@ comment at the start of cc-engine.el for more info." | |||
| 12711 | (c-back-over-member-initializers) | 12718 | (c-back-over-member-initializers) |
| 12712 | (point))) | 12719 | (point))) |
| 12713 | (c-most-enclosing-brace state-cache (point)))) | 12720 | (c-most-enclosing-brace state-cache (point)))) |
| 12714 | (c-beginning-of-statement-1 lim) | 12721 | (c-beginning-of-statement-1 lim nil nil t) |
| 12715 | (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state))) | 12722 | (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state))) |
| 12716 | 12723 | ||
| 12717 | ;; CASE 9D: this is just a later brace-list-entry or | 12724 | ;; CASE 9D: this is just a later brace-list-entry or |