Emacs kaizen: ace-isearch combines ace-jump-mode and helm-swoop
Posted: - Modified: | emacsI’m a fan of clever little things that change their behaviour depending on what you’re doing while letting you mentally think of it as just one function.
ace-isearch
looks like it’ll be useful for collapsing three different functions into one mental thing in my head:
- jumping to a specific character that I can see (ace-jump-mode)
- searching through a buffer for a few characters (isearch)
- doing
helm-swoop
to quickly preview and navigate through matching lines in a buffer
If you install the ace-isearch
package and turn on global-ace-isearch-mode
, then searching for a single character triggers ace-jump-mode
, searching for less than 5 characters triggers isearch
, and anything longer triggers helm-swoop-from-isearch
. You can customize those thresholds, of course.
Neat!
5 comments
rsihell
2015-01-24T01:27:40ZJust found this, brilliant! For a simple hack to make searching even more efficient I've added defadvice to check if a region is marked in which case it searches for that:
(defadvice isearch-forward (around search-standard-or-selection-forward activate)
(if (use-region-p)
(search-selection (region-beginning) (region-end))
ad-do-it))
Now all that's missing is for emacs to read my mind (or predict) what I will search for. Hmm....
sachac
2015-01-26T19:15:43ZHmm, you're right, maybe I should get ace-isearch to do something similar... Usually, if I want to search within a region, I'll just narrow to it anyway. =)
Jaehyun Yeom
2015-01-27T03:21:17ZNot sure if I'm understanding correctly, but the downside may be when we want to jump to change the region range. The pattern I use often is C-Spc to set mark (transient-mark) and page down a bit and C-s to jump to the end of the region that I want to set when I see it.
sachac
2015-01-28T18:34:51ZHmmm... I know there are all sorts of keyboard shortcuts in isearch and helm-swoop that I haven't explored yet. There's probably already a quick way to pull in the current word or region. C-w copies in the next character or word, apparently. Let me think about what an interesting behaviour might be like... Maybe one could hit different keys depending on whether you want to search only within the region, or copy the region into the string, or use that as the beginning of the region and then search for what will be the end of the region? I'm not sure if I'm going to remember or use all that, though... =) With Emacs, the toughest part is usually figuring out what you want Emacs to behave like!
Jaehyun Yeom
2015-01-27T01:54:34ZCool! I was just wondering how I could combine isearch-* and helm-swoop. Thank you very much!