]> code.delx.au - gnu-emacs-elpa/commitdiff
* sm-c-mode/sm-c-mode.el (sm-c-smie-rules): Improve indent of enum's {...}
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 25 Jan 2016 13:24:41 +0000 (08:24 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 25 Jan 2016 13:24:41 +0000 (08:24 -0500)
packages/sm-c-mode/sm-c-mode.el

index a64382973c87f295d127b7fbd4718a969ff9f00c..54b9a54ee377ef46f418a52ba0c0c033baa3f03c 100644 (file)
@@ -640,6 +640,16 @@ if INNER is non-nil, it stops at the innermost one."
                                   0
                                 (funcall smie-rules-function :elem 'basic))
                               (smie-indent-virtual))))
+              ((and (member tok '("enum" "struct"))
+                    ;; Make sure that the {...} is about this struct/enum, as
+                    ;; opposed to "struct foo *get_foo () {...}"!
+                    (save-excursion
+                      (smie-indent-forward-token)
+                      (smie-indent-forward-token)
+                      (forward-comment (point-max))
+                      (>= (point) pos)))
+               `(column . ,(+ (funcall smie-rules-function :elem 'basic)
+                              (smie-indent-virtual))))
               ((or (member tok sm-c-paren-block-keywords)
                    (equal tok "do"))
                nil)