Komodo IDE macro to process current file with PHP Beautifier

I use Komodo IDE for dynamic languages. I like it because it works extremely well and you get a license to use it on whatever machine you happen to be sitting at. Also it works well in Ubuntu and Mac OS/X, both of which I use constantly.

Here’s a macro I use in Komodo to make the file I am currently editing instantly pretty:

var ke = komodo.editor
if (komodo.view.scintilla) { komodo.view.scintilla.focus(); }
var currentPos = komodo.editor.currentPos;
 
try {
    var tidycmd = "/usr/bin/php_beautifier -t1 -l 'Pear() ArrayNested IndentStyles() NewLines'"
    komodo.doCommand('cmd_save');
    ke.beginUndoAction();
    komodo.doCommand('cmd_selectAll');
    Run_RunEncodedCommand(window, tidycmd + " {'insertOutput': True, 'operateOnSelection': True}");
    ke.gotoPos(currentPos);
    komodo.doCommand('cmd_cleanLineEndings');
} catch (e) {
    alert(e);
} finally {
    ke.endUndoAction();
}

Be Sociable, Share!