How to invoke am (atom) package command by command name (emacs style)


#1

atom commands have names, ex: “symbols-view:go-to-declaration”

is there a shell within atom that I can just enter the-name-of-the-command", that will have it executed ?


#2

Yes and no. Yes, there is the built-in command-palette package. No in that not all commands are intended to be executed by the user. Some are only designed to be executed within certain contexts and won’t work outside of those contexts.


#3

Advanced answer: you can use atom.commands.dispatch() to invoke a command with a context you give it, and you can do this from the JS console (which would act as a shell in this instance). The caveat is that your mileage is guaranteed to vary and the dispatch() function cannot ensure that the command will be meaningful when executed or that a poorly-written command will not run off on an endless synchronous loop if it receives a context or data that it didn’t anticipate. Atom gives packages almost complete control and it assumes that anything a package tells it to do has been blessed by the user.


#4

The feature I’m talking about is similar to emacs Alt-X : it opens a shel, you can then type a command when typing you are in incremental search mode, i.e. you see a drop down of commands that start with the name. It’s a very efficient way to search for commands by guessing prefixes, ex: you type “search” then you see “search-word”, “seach-in-all-project”, search-symbol, etc…
In other words the shell serves not only as a invoker of commands, but also as a way to discover what is available.

It’s one of emacs the adictive features… It seems that the philosophy of atom is similar to emcs, why not copy emac’s best feature ? :wink:


#5

The Command Palette does what you describe. What do you feel like it is missing?