1

How can I use this emacs style in my emacs?

And how can I format all my existing code using this style?

1 Answer 1

0

Quoting the documentation embedded as comments in the linked file:

;; Provides the google C/C++ coding style. You may wish to add
;; `google-set-c-style' to your `c-mode-common-hook' after requiring this
;; file. For example:
;;
;;    (add-hook 'c-mode-common-hook 'google-set-c-style)

What this means is that you should copy the google-c-style.el file somewhere Emasc will find it (in your ~/.emacs.d directory, for example). Then add the following lines in your init file:

(require 'google-c-style)
(add-hook 'c-mode-common-hook 'google-set-c-style)

As to formatting existing code using this style, in any given buffer you can use

  • C-xh : select the entire buffer contents
  • C-M-\ : indent the region

If you have a whole lot of open buffers, you can use ibuffer to automate reindenting all of them:

  • M-xibufferRET : open the buffers list
  • mark all buffers to be indented (for example using m)
  • E(indent-region (point-min) (point-max))RET : reindent all marked buffers
  • S : save all marked buffers if you are satisfied with the result

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .