Replacing Raycast With Emacs, Ep 2 - Bang Commands

Replacing Raycast With Emacs, Ep 2 - Bang Commands

Adding DuckDuckGo-style bang commands to the Emacs launcher.

This is a series of notes documenting my effort on replacing my most frequently used mac apps with Emacs. This is the Raycast edition.
bang command in launcher

Another Raycast feature I reach for constantly: bang commands. !g to search Google, !yt for YouTube, !gh for GitHub. Type a bang shortcut, hit space, type your query — it redirects to the right search engine without leaving the launcher.

Getting this into launcher.el took some tinkering.

The behavior I wanted: when you type a recognized bang command at the start of input and press space, the launcher enters "bang mode". The candidate list clears. Whatever you type next becomes the search query, sent to the configured URL template when you hit enter.

The tricky part is the mode transition. The launcher normally filters candidates as you type — that behavior needs to suspend the moment a bang prefix is confirmed. I hooked into the post-command logic to detect the pattern (bang token followed by a space at point), set a flag, and swap out the candidate source with a passthrough that just holds the query string.

I'm not proficient in elisp, so I leaned on Claude Code to work through the implementation. It might not be idiomatic — there are probably cleaner ways to handle the state transition. But it works, and the behavior matches what I had in Raycast.

If you spot something obviously wrong, do let me know.