I really like M-x occur. It’s like grep for your buffers.
I also like C-s to search. Interactive search is great if you sort of know what you, and you just want the next, and the next, and one more. But usually searching ends up being a learning experience. After hitting C-s a few times you realize: I’m lost – there are too many matches.
You need M-x occur to get an overview. How to get from isearch to occur without loosing your search string?
(defun isearch-occur () "Invoke `occur' from within isearch." (interactive) (let ((case-fold-search isearch-case-fold-search)) (occur (if isearch-regexp isearch-string (regexp-quote isearch-string))))) (define-key isearch-mode-map (kbd "C-o") 'isearch-occur)
Hit C-o while you’re still in isearch.
The code will do the right thing both for C-s and C-M-s (which runs the command isearch-forward-regexp).
Also available on the wiki @ OccurFromIsearch.
#Emacs
(Please contact me if you want to remove your comment.)
⁂
Also note that isearch-occur already exists in Emacs 23 (on `M-s o’).
– bojohan 2008-09-05 19:57 UTC
---
Yay! 😄
– Alex Schroeder 2008-09-05 21:42 UTC