Group Emacs Search Functions using Hydra
17 Apr 2015I am a search-guy: when I want to know something, I use the search functionality to locate to where has the keyword, and I didn't use my eyes to scan the page, it's too slow and harmful.
Emacs provides powerful functionality to do searching. For example, I use these commands very often (with the key-binds),
isearch
(C-s
), search for a string and move the cursor to there,helm-swoop
(C-F1
), find all the occurrences of a string, pull out the lines containing the string to another buffer where I can edit and save,helm-multi-swoop
M-X
, applyhelm-swoop
to multiple buffers, very handy if I want to know where a function is called in different buffers.projectile-grep
orhelm-projectile-grep
C p s g
, find which files in current project contains a specific string, similar tohelm-multi-swoop
limits the search to files in project directory.
I love doing searching in Emacs, but the problem is to have to remember all the key-binds for different tasks. Also, sometimes, I forgot about what alternatives I have and usually go with the one that I most familiar with, which usually means not the right one. I sometimes realise I use isearch
multiple times to do what ace-jump-word-mode
can achieve by just once.
Org-mode Hydras incoming! gives me some idea to group all these functions together, and press a single key to perform different tasks, so this can free my mind from remembering all the key-binds. Also, I can write the few lines of text to reminds myself when to do what, and this potentially can solve problem two.
Here is the hydra implementation for searching:
So next time, when I want to search something, I just press F4, and then it brings up all the choices I have, and I don't need to worry about the key-binds or which to use! That's cool!
I am looking forward simplifying my Emacs workflow using hydra
package, the key challenge is to identify the logical similarities among the tasks and then group them together accordingly. For hydra-search()
, it is "search something on somewhere".