diff --git a/personal/c-style.el b/personal/c-style.el index 39554fa50a..b05793722b 100644 --- a/personal/c-style.el +++ b/personal/c-style.el @@ -40,12 +40,14 @@ (c-toggle-electric-state 1) (c-toggle-auto-newline -1)) -;; (add-hook 'c++-mode-hook 'snail-style-c++-mode-hook) -(add-hook 'prelude-c-mode-common-hook 'snail-style-c++-mode-hook) +;; (add-hook 'prelude-c-mode-common-hook 'snail-style-c++-mode-hook) (add-hook 'prelude-c-mode-common-hook 'ggtags-mode) ;; Use C++ style for IDL files -(add-hook 'idl-mode-hook 'snail-style-c++-mode-hook) +;; (add-hook 'idl-mode-hook 'snail-style-c++-mode-hook) + +(add-hook 'prelude-c-mode-common-hook 'google-set-c-style) +(add-hook 'idl-mode-hook 'google-set-c-style) ;; (sp-local-pair 'c-mode "(" nil :pre-handlers '(:rem " ")) ;; (sp-local-pair 'c++-mode "(" nil :pre-handlers '(:rem " ")) diff --git a/personal/caleb.el b/personal/caleb.el index b8079a75c2..a145fdc9b8 100644 --- a/personal/caleb.el +++ b/personal/caleb.el @@ -73,7 +73,7 @@ ;; (global-ede-mode 1) ;; CEDET holdover ;; (add-hook 'c-mode-common-hook 'fci-mode) (add-hook 'c-mode-common-hook 'company-mode) -(add-hook 'c-mode-common-hook 'linum-mode) +(add-hook 'prelude-prog-mode-hook 'linum-mode t) ;; (add-hook 'c-mode-common-hook 'hs-minor-mode) ;; (add-hook 'c-mode-common-hook 'hideshowvis-minor-mode) @@ -92,5 +92,22 @@ ;; I use underscore to mean underscore in my org-mode files (setq org-export-with-sub-superscripts nil) +;; Jesus christ, company + shell scripts is a mess +(setq company-global-modes '(not shell-script-mode)) + +;; From https://eklitzke.org/smarter-emacs-clang-format. Enable +;; clang-format if the Projectile root has a .clang-format +(require 'f) +(defun clang-format-buffer-smart () + "Reformat buffer if .clang-format exists in the projectile root." + (when (f-exists? (expand-file-name ".clang-format" (projectile-project-root))) + (clang-format-buffer))) + +(defun clang-format-buffer-smart-on-save () + "Add auto-save hook for clang-format-buffer-smart." + (add-hook 'before-save-hook 'clang-format-buffer-smart nil t)) + +(add-hook 'c-mode-common-hook 'clang-format-buffer-smart-on-save t) + ;; Start the server (server-start)