This file contains 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
(defun c-indent-file (filename) | |
(interactive) | |
(find-file filename) | |
(mark-whole-buffer) | |
(c-indent-line-or-region) | |
(save-buffer)) |
But you don't want to manually open each file into an Emacs buffer to execute this script. Emacs batch editing to the rescue:
This file contains 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
emacs --batch -l '/home/dburger/.emacs' --eval '(c-indent-file "/home/dburger/test.c")' |
The parameters load up my .emacs file as normal and runs the given eval. Apply a little command line magic and you should be able to exploit Emacs from the command line in a very efficient way.