emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113997: Improve indentation of bracelists defined b


From: Alan Mackenzie
Subject: [Emacs-diffs] trunk r113997: Improve indentation of bracelists defined by macros (without "=").
Date: Sun, 25 Aug 2013 21:08:12 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113997
revision-id: address@hidden
parent: address@hidden
committer: Alan Mackenzie <address@hidden>
branch nick: trunk
timestamp: Sun 2013-08-25 21:06:07 +0000
message:
  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 ";".
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/progmodes/cc-engine.el    
ccengine.el-20091113204419-o5vbwnq5f7feedwu-1227
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-08-25 13:52:14 +0000
+++ b/lisp/ChangeLog    2013-08-25 21:06:07 +0000
@@ -1,5 +1,11 @@
 2013-08-25  Alan Mackenzie  <address@hidden>
 
+       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 ";".
+
        Parse C++ inher-intro when there's a template split over 2 lines.
 
        * progmodes/cc-engine.el (c-guess-basic-syntax CASE 5C): Code more

=== modified file 'lisp/progmodes/cc-engine.el'
--- a/lisp/progmodes/cc-engine.el       2013-08-25 13:52:14 +0000
+++ b/lisp/progmodes/cc-engine.el       2013-08-25 21:06:07 +0000
@@ -8476,10 +8476,10 @@
            ;; 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 @@
                                          ))))
                                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))
    ))
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]