yasuyk / web-beautify

Format HTML, CSS and JavaScript/JSON by js-beautify
GNU General Public License v3.0
219 stars 21 forks source link

Unnecessary tmp files? #8

Open jacksonrayhamilton opened 10 years ago

jacksonrayhamilton commented 10 years ago

Your implementation saves the output of js-beautify to a tmp file. Can you not simply replace the input region with the shell command's output?

(shell-command-on-region START END COMMAND &optional OUTPUT-BUFFER REPLACE ERROR-BUFFER DISPLAY-ERROR-BUFFER) ... Optional fourth arg OUTPUT-BUFFER specifies where to put the command's output. If the value is a buffer or buffer name, put the output there. Any other value, including nil, means to insert the output in the current buffer. In either case, the output is inserted after point (leaving mark after it).

Optional fifth arg REPLACE, if non-nil, means to insert the output in place of text from START to END, putting point and mark around it.

(shell-command-on-region (point-min) (point-max) "js-beautify -f -" nil t)