I very like Emmet and AutoCode. And with the “Autocode” plugin i can expand something abbreviations by tab button. Any ideas to set the tab button for “expand abbreviation” command?
You’re basically asking to connect two actions to the same keybind, this is not something that is supported by Komodo but you could make your own macro that basically handles this behaviour for you, ie. TAB triggers your macro, which then passes it on to Emmet or AutoCode as applicable. You’d have to get down and dirty with their API’s though.
Alternatively you could ask @davestewart if he’d consider adding in Emmet support to his Autocode addon.
Okay, i’m trying to write a custom macro. But where I can find a tutorial or guide about macro?)
Have a look at the info given on our Customize page.
Much of the info regarding Addon development applies to Macros as well. Macros are essentially single file addons.
Yeah, AutoCode uses JavaScript keyboard event listeners to trigger its code. I would have rather plugged into the Komodo system, but to be honest, couldn’t figure out how to do it (or maybe I wasn’t getting the results I wanted). Either way, I really view it as a bit of a hack - but one that works without too many side-effects - so it’s OK for the time being.
I wrote a library to abstract keyboard input as I’m dealing with various plugins, but you should be OK just using straight JavaScript.
The main thing to be careful of when adding handlers manually is making sure you don’t add multiple handlers when re-running your plugin. I use a method as follows to manage this:
if (window.somePlugin)
{
somePlugin.destroy();
}
somePlugin =
{
init:function()
{
window.addEventListener('keydown', this.onKeyDown);
},
destroy:function()
{
window.removeEventListener('keydown', this.onKeyDown);
},
onKeyDown:function(event)
{
trace(event.keyCode);
}
}
somePlugin.init();
Not sure if there is a better way… @nathanr ?
Also, for writing and testing plugins, AutoCode is your friend. Pressing CTRL+Enter in any JavaScript window will run that JS code right within Komodo. Use the trace() or inspect() commands to write directly to the Command Output panel.
That looks good to me, we do try to use the extensions namespace for our Macros, but that might change with all the API changes in Komodo 9.
On the same topic, what is / is there an extensible way to piggyback Komodo’s Key Bindings mechanism?
You’d likely be looking at hooking into the keybindingManager if/where possible. In case of the tab character things get a bit more complicated though as it’s also used by Auto-Abbreviations (Prefs > Editor > Smart Editing), which far as I can tell basically make the functionality you’re providing in AutoCode redundant.
@ericp will be able to shed more light on this, in case you’re still interested.