Update google-c-style.el to #33.

Review URL: https://codereview.appspot.com/8717044
This commit is contained in:
erg@google.com 2013-04-12 21:15:03 +00:00
parent 8190c132fd
commit 5de56f3124

View File

@ -37,14 +37,14 @@
(defun google-c-lineup-expression-plus-4 (langelem) (defun google-c-lineup-expression-plus-4 (langelem)
"Indents to the beginning of the current C expression plus 4 spaces. "Indents to the beginning of the current C expression plus 4 spaces.
This implements title \"Function Declarations and Definitions\" of the Google This implements title \"Function Declarations and Definitions\"
C++ Style Guide for the case where the previous line ends with an open of the Google C++ Style Guide for the case where the previous
parenthese. line ends with an open parenthese.
\"Current C expression\", as per the Google Style Guide and as clarified by \"Current C expression\", as per the Google Style Guide and as
subsequent discussions, clarified by subsequent discussions, means the whole expression
means the whole expression regardless of the number of nested parentheses, but regardless of the number of nested parentheses, but excluding
excluding non-expression material such as \"if(\" and \"for(\" control non-expression material such as \"if(\" and \"for(\" control
structures. structures.
Suitable for inclusion in `c-offsets-alist'." Suitable for inclusion in `c-offsets-alist'."
@ -53,10 +53,15 @@ Suitable for inclusion in `c-offsets-alist'."
;; Go to beginning of *previous* line: ;; Go to beginning of *previous* line:
(c-backward-syntactic-ws) (c-backward-syntactic-ws)
(back-to-indentation) (back-to-indentation)
(cond
;; We are making a reasonable assumption that if there is a control ;; We are making a reasonable assumption that if there is a control
;; structure to indent past, it has to be at the beginning of the line. ;; structure to indent past, it has to be at the beginning of the line.
(if (looking-at "\\(\\(if\\|for\\|while\\)\\s *(\\)") ((looking-at "\\(\\(if\\|for\\|while\\)\\s *(\\)")
(goto-char (match-end 1))) (goto-char (match-end 1)))
;; For constructor initializer lists, the reference point for line-up is
;; the token after the initial colon.
((looking-at ":\\s *")
(goto-char (match-end 0))))
(vector (+ 4 (current-column))))) (vector (+ 4 (current-column)))))
(defconst google-c-style (defconst google-c-style
@ -69,6 +74,8 @@ Suitable for inclusion in `c-offsets-alist'."
(defun-close before after) (defun-close before after)
(class-open after) (class-open after)
(class-close before after) (class-close before after)
(inexpr-class-open after)
(inexpr-class-close before)
(namespace-open after) (namespace-open after)
(inline-open after) (inline-open after)
(inline-close before after) (inline-close before after)
@ -87,8 +94,9 @@ Suitable for inclusion in `c-offsets-alist'."
. (c-semi&comma-no-newlines-for-oneline-inliners . (c-semi&comma-no-newlines-for-oneline-inliners
c-semi&comma-inside-parenlist c-semi&comma-inside-parenlist
c-semi&comma-no-newlines-before-nonblanks)) c-semi&comma-no-newlines-before-nonblanks))
(c-indent-comments-syntactically-p . nil) (c-indent-comments-syntactically-p . t)
(comment-column . 40) (comment-column . 40)
(c-indent-comment-alist . ((other . (space . 2))))
(c-cleanup-list . (brace-else-brace (c-cleanup-list . (brace-else-brace
brace-elseif-brace brace-elseif-brace
brace-catch-brace brace-catch-brace
@ -119,7 +127,7 @@ Suitable for inclusion in `c-offsets-alist'."
(statement-case-intro . +) ; case w/o { (statement-case-intro . +) ; case w/o {
(access-label . /) (access-label . /)
(innamespace . 0)))) (innamespace . 0))))
"Google C/C++ Programming Style") "Google C/C++ Programming Style.")
(defun google-set-c-style () (defun google-set-c-style ()
"Set the current buffer's c-style to Google C/C++ Programming "Set the current buffer's c-style to Google C/C++ Programming