Open the file, and then backtrack it, holding the entire area:
Mx find-file /path/to/file RET Cx h (Mx mark-whole-buffer) CM-\ (Mx indent-region)
Now it looks like you are trying to indent C into a buffer that is not in C mode. To switch to C mode
Mx c-mode
Or c++-mode or any other mode. But, since this is assembler code, you probably need assembly mode (which Emacs will do by default for .s files). In this case, the indent command above ( CM-\ also known as Mx indent-region ) should work for you.
Note: the sequence of commands from above can be folded into one command as follows:
(defun indent-file (file) "prompt for a file and indent it according to its major mode" (interactive "fWhich file do you want to indent: ") (find-file file) ;; uncomment the next line to force the buffer into a c-mode ;; (c-mode) (indent-region (point-min) (point-max)))
And if you want to learn how to associate basic modes with files based on extensions, see the documentation for auto-mode-alist . In fairness, this is not necessarily an extension based, just regular expressions matching the file name.
Trey Jackson Jun 14 '09 at 13:43 2009-06-14 13:43
source share