I'm trying to write a small program to indent lisp files using
lisp-mode so I can get Emacs-compatible indentation even when using a different program.
Here's my first attempt to write a program to visit a file, override its mode and, indent it, and then write it back.
I'm wondering if there's a way to non-interactively open a buffer to a file without enabling the modes associated with that file. It seems more elegant than enabling
text-mode and then
#!/bin/sh :;exec /usr/bin/env emacs -Q --script "$0" "$@" (mapcar (lambda (filename) (find-file filename) (text-mode) (lisp-mode) (indent-region (point-min) (point-max)) (basic-save-buffer)) argv)
I copied the file into
indent2.el and ran
indent.el a few times with
indent2 as an argument.
It seems to be working correctly, but produces the message
> ./indent.el ./indent2.el Setting up indent for shell type sh Indentation variables are now local. Indentation setup for shell type sh Indenting region... Indenting region...done
which means that Emacs is processing the shebang even when being used non-interactively. Is there a way to get it to bypass that step?