Author: Andreas PolitzAndreas Politz Date: Aug 26, 2008 09:10
filebat Mark wrote:
> I have wrote the following elisp function. I think it works from my side.
> Hopes it's useful for someone else.
>
>
> (global-set-key [M-f12] 'my_indent_code);;indent code
> (defun my_indent_code()
> (interactive)
> ;;remove blank lines
> (goto-char 0)
> (flush-lines "^$")
> (save-buffer)
> (setq current_filename (buffer-name (current-buffer)))
> ;;indent the code, add or remove some space
> (setq commandline "indent ")
> (setq commandline (concat commandline current_filename))
> (shell-command-to-string commandline)
> ;;convert the line endings of text files from DOS style to unix style
> (setq commandline "dos2unix ")
> (setq commandline (concat commandline current_filename)) ...
|