Created
February 16, 2017 12:39
-
-
Save longjie/c4ea4c04a7426eff68cf083ea936446d to your computer and use it in GitHub Desktop.
Emacs setting to run GNU indent automatically after save C/C++ files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Function to format C/C++ code with GNU indent | |
(defun c-auto-format () | |
"Function to format C/C++ code with GNU indent" | |
(interactive) | |
(when (find major-mode '(c-mode c++-mode)) | |
(shell-command | |
(format "indent %s" (shell-quote-argument (buffer-file-name)))) | |
(revert-buffer t t t))) | |
;; Add after-save-hook | |
(add-hook 'after-save-hook 'c-auto-format) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment