I am trying to create an Emacs script that indents HTML files from the command line. This is what I have so far:
#!/usr/bin/env -S emacs --script
(require 'web-mode)
(indent-region (point-min) (point-max) nil)
(save-buffer)
I saved this file as indent
and made it executable with chmod 755 indent
. Then, I tried running it on an HTML file:
$ ./indent base.html
Loading /etc/emacs/site-start.d/00debian.el (source)...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50cmake-data.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading /etc/emacs/site-start.d/50figlet.el (source)...
Loading /etc/emacs/site-start.d/50gettext.el (source)...
Package gettext-el removed but not purged. Skipping setup.
Loading /etc/emacs/site-start.d/50latexmk.el (source)...
Loading /etc/emacs/site-start.d/50pylint.el (source)...
Indenting region...
Indenting region...done
It seemed to work, but there is no output. The content of file base.html
remains unchanged. I'd really like to get this working, because I want to use this command as a git hook to format HTML files using web-mode.el
.
Could anyone help?