Call atom command from package?


#1

It would be wonderful to be able to call a command in a different package by name – like atom.workspaceView.perform_command "editor:move-to-end-of-line".

It would make a macro package possible, for one, but it would also let me add hooks to my package – the user could say "before you run that, call rspec:run-last.

Is there a way to do this? I feel like I must just be missing it, but I haven’t run across it reading anyone else’s code.


#2

command actually call jquery.on, so I think maybe trigger will do


#3

Hey, sure enough! It does!

atom.workspaceView.trigger("name:command") works great.

Thanks!


#4

workspaceView no longer exists. instead, you may call:

atom.commands.dispatch(atom.views.getView(atom.workspace), "name:command");