summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-engine.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2013-08-25 21:06:07 +0000
committerAlan Mackenzie <acm@muc.de>2013-08-25 21:06:07 +0000
commit8a51e842321a59943df63faa97d98a390e22211a (patch)
treeb753da81be84e6c7c9b19c86f6d3a112a0d23072 /lisp/progmodes/cc-engine.el
parente687aa335a21662f67d2d73063272504a171ffab (diff)
downloademacs-8a51e842321a59943df63faa97d98a390e22211a.tar.gz
Improve indentation of bracelists defined by macros (without "=").
* progmodes/cc-engine.el (c-inside-bracelist-p): When a macro expansion begins with "{", regard it as bracelist when it doesn't contain a ";".
Diffstat (limited to 'lisp/progmodes/cc-engine.el')
-rw-r--r--lisp/progmodes/cc-engine.el52
1 files changed, 34 insertions, 18 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 3d6398014db..b9345b2ae6a 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -8476,10 +8476,10 @@ comment at the start of cc-engine.el for more info."
;; check for the class key here.
(and (c-major-mode-is 'pike-mode)
c-decl-block-key))
- bufpos braceassignp lim next-containing)
+ bufpos braceassignp lim next-containing macro-start)
(while (and (not bufpos)
containing-sexp)
- (when paren-state
+ (when paren-state
(if (consp (car paren-state))
(setq lim (cdr (car paren-state))
paren-state (cdr paren-state))
@@ -8560,22 +8560,38 @@ comment at the start of cc-engine.el for more info."
))))
nil)
(t t))))))
- (if (and (eq braceassignp 'dontknow)
- (/= (c-backward-token-2 1 t lim) 0))
- (setq braceassignp nil)))
- (if (not braceassignp)
- (if (eq (char-after) ?\;)
- ;; Brace lists can't contain a semicolon, so we're done.
- (setq containing-sexp nil)
- ;; Go up one level.
- (setq containing-sexp next-containing
- lim nil
- next-containing nil))
- ;; we've hit the beginning of the aggregate list
- (c-beginning-of-statement-1
- (c-most-enclosing-brace paren-state))
- (setq bufpos (point))))
- )
+ (if (and (eq braceassignp 'dontknow)
+ (/= (c-backward-token-2 1 t lim) 0))
+ (setq braceassignp nil)))
+ (cond
+ (braceassignp
+ ;; We've hit the beginning of the aggregate list.
+ (c-beginning-of-statement-1
+ (c-most-enclosing-brace paren-state))
+ (setq bufpos (point)))
+ ((eq (char-after) ?\;)
+ ;; Brace lists can't contain a semicolon, so we're done.
+ (setq containing-sexp nil))
+ ((and (setq macro-start (point))
+ (c-forward-to-cpp-define-body)
+ (eq (point) containing-sexp))
+ ;; We've a macro whose expansion starts with the '{'.
+ ;; Heuristically, if we have a ';' in it we've not got a
+ ;; brace list, otherwise we have.
+ (let ((macro-end (progn (c-end-of-macro) (point))))
+ (goto-char containing-sexp)
+ (forward-char)
+ (if (and (c-syntactic-re-search-forward "[;,]" macro-end t t)
+ (eq (char-before) ?\;))
+ (setq bufpos nil
+ containing-sexp nil)
+ (setq bufpos macro-start))))
+ (t
+ ;; Go up one level
+ (setq containing-sexp next-containing
+ lim nil
+ next-containing nil)))))
+
bufpos))
))