User Tools

Site Tools


user:mhoram:scripts:indent_a_file

This is a simple lisp function for Emacs (or XEmacs) that indents a file and removes all tabs, according to the Crossfire programming guide.

;;; Fixes the indentation of a file at 4 spaces per indent,
;;; and replaces all tabs with spaces.
;;; To use on code.c in batch mode, save as indent.el, and run:
;;;
;;; emacs -batch code.c -l indent.el -f indent-a-file -kill
;;;
(defun indent-a-file ()
  (setq c-basic-offset 4)
  (indent-region (point-min) (point-max) nil)
  (untabify (point-min) (point-max))
  (save-buffer)
)
user/mhoram/scripts/indent_a_file.txt · Last modified: 2007/01/25 19:24 (external edit)