Created
May 16, 2018 13:36
-
-
Save AloisJanicek/2b47dbfa4e73540d86fa8dbc6e490f93 to your computer and use it in GitHub Desktop.
Run `html-beautify on html file opened in Emacs buffer when saving it
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 beautify-html-file-and-revert () | |
"Beautify file with html-beautify and only if major mode is web-mode" | |
(interactive) | |
(when (eq major-mode 'web-mode) | |
(message "html-beautify taking care of your markup" (buffer-file-name)) | |
(shell-command (concat "html-beautify --quiet --replace -s 2 -I -E \"\" --max-preserve-newlines 0 -f " (buffer-file-name))) | |
(revert-buffer t t))) | |
(add-hook 'after-save-hook #'beautify-html-file-and-revert) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment