diff options
| author | Alan Mackenzie | 2017-11-10 17:45:22 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2017-11-10 17:45:22 +0000 |
| commit | 096f638ddc806db875fa5bf90bb3be17b6893821 (patch) | |
| tree | d0b639f183b6765653eb78e22a0e6ee4394744b3 | |
| parent | c52a2aa8f363f7f7a32119948ed73b7e4a0772ef (diff) | |
| download | emacs-096f638ddc806db875fa5bf90bb3be17b6893821.tar.gz emacs-096f638ddc806db875fa5bf90bb3be17b6893821.zip | |
Correct the indentation of C99's compound literals.
* lisp/progmodes/cc-engine.el (c-looking-at-statement-block): Amend so that
if there is only syntactic whitespace in a brace block, it is regarded as a
statement block. Also, if there is no semicolon or comma delimiter, treat as
a statement block when there is a keyword.
(c-guess-basic-syntax): CASE 9 test: Regard a brace as starting a brace block
when its contents indicate a brace block.
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 982be3bb3b9..8ec01e1810b 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -10726,26 +10726,35 @@ comment at the start of cc-engine.el for more info." | |||
| 10726 | 10726 | ||
| 10727 | (defun c-looking-at-statement-block () | 10727 | (defun c-looking-at-statement-block () |
| 10728 | ;; Point is at an opening brace. If this is a statement block (i.e. the | 10728 | ;; Point is at an opening brace. If this is a statement block (i.e. the |
| 10729 | ;; elements in it are terminated by semicolons) return t. Otherwise, return | 10729 | ;; elements in the block are terminated by semicolons, or the block is |
| 10730 | ;; nil. | 10730 | ;; empty, or the block contains a keyword) return t. Otherwise, return nil. |
| 10731 | (let ((here (point))) | 10731 | (let ((here (point))) |
| 10732 | (prog1 | 10732 | (prog1 |
| 10733 | (if (c-go-list-forward) | 10733 | (if (c-go-list-forward) |
| 10734 | (let ((there (point))) | 10734 | (let ((there (point))) |
| 10735 | (backward-char) | 10735 | (backward-char) |
| 10736 | (c-syntactic-skip-backward | 10736 | (c-syntactic-skip-backward "^;," here t) |
| 10737 | "^;," here t) | ||
| 10738 | (cond | 10737 | (cond |
| 10739 | ((eq (char-before) ?\;) t) | 10738 | ((eq (char-before) ?\;) t) |
| 10740 | ((eq (char-before) ?,) nil) | 10739 | ((eq (char-before) ?,) nil) |
| 10741 | (t (goto-char here) | 10740 | (t ; We're at (1+ here). |
| 10742 | (forward-char) | 10741 | (cond |
| 10743 | (and (c-syntactic-re-search-forward "{" there t t) | 10742 | ((progn (c-forward-syntactic-ws) |
| 10744 | (progn (backward-char) | 10743 | (eq (point) (1- there))) |
| 10745 | (c-looking-at-statement-block)))))) | 10744 | t) |
| 10745 | ((c-syntactic-re-search-forward c-keywords-regexp there t) | ||
| 10746 | t) | ||
| 10747 | ((c-syntactic-re-search-forward "{" there t t) | ||
| 10748 | (backward-char) | ||
| 10749 | (c-looking-at-statement-block)) | ||
| 10750 | (t nil))))) | ||
| 10746 | (forward-char) | 10751 | (forward-char) |
| 10747 | (and (c-syntactic-re-search-forward "[;,]" nil t t) | 10752 | (cond |
| 10748 | (eq (char-before) ?\;))) | 10753 | ((c-syntactic-re-search-forward "[;,]" nil t t) |
| 10754 | (eq (char-before) ?\;)) | ||
| 10755 | ((c-syntactic-re-search-forward c-keywords-regexp nil t t) | ||
| 10756 | t) | ||
| 10757 | (t nil))) | ||
| 10749 | (goto-char here)))) | 10758 | (goto-char here)))) |
| 10750 | 10759 | ||
| 10751 | (defun c-looking-at-inexpr-block (lim containing-sexp &optional check-at-end) | 10760 | (defun c-looking-at-inexpr-block (lim containing-sexp &optional check-at-end) |
| @@ -12534,7 +12543,11 @@ comment at the start of cc-engine.el for more info." | |||
| 12534 | (save-excursion | 12543 | (save-excursion |
| 12535 | (goto-char containing-sexp) | 12544 | (goto-char containing-sexp) |
| 12536 | (c-looking-at-special-brace-list))) | 12545 | (c-looking-at-special-brace-list))) |
| 12537 | (c-inside-bracelist-p containing-sexp paren-state t)))) | 12546 | (c-inside-bracelist-p containing-sexp paren-state t) |
| 12547 | (save-excursion | ||
| 12548 | (goto-char containing-sexp) | ||
| 12549 | (and (eq (char-after) ?{) | ||
| 12550 | (not (c-looking-at-statement-block))))))) | ||
| 12538 | (cond | 12551 | (cond |
| 12539 | 12552 | ||
| 12540 | ;; CASE 9A: In the middle of a special brace list opener. | 12553 | ;; CASE 9A: In the middle of a special brace list opener. |