Searching multiple buffers emacs
July 27, 2008
In the past I’ve complained about emacs not being able to search multiple buffers for regular expressions, and I’ve resorted to using the additional package moccur.el. This was pretty good but had the irritating (though understandable) caveat that if you changed the text in one of the searced files then all the links from the output pane became slightly wrong.
However, I take it all back. I’ve just found that the standard FSF emacs has two functions which do what I want to do without these caveats. These allow one to search several buffers simultaneously for a given regexp and maintain links even if context is chaged… I’m not quite sure how I managed to miss this before – since the first thing that one would think to do if you wanted to search multiple strings for buffers would be to type “C-h a o-c-c-u-r-<ENTER>” and then search for multi… but I guess I’m just dim.
Anyway:
Precis for the impatient
In FSF emacs, you can search several buffers for a given string
multi-occur: – Search specified buffers to a string
multi-occur-in-matching-buffers: Allows one to search a subset of one’s open buffers or files specified as a regexp:
Given .* as its first argument this allows one to search all currently open files for a given regular expression.
Given a prefix argument and .* as its first argument this allows one to search all currently open buffers for a regexp.
Also (occur-1 regexp nil buffer-list) can be usefully adapted to search for other things.
Entry Filed under: Uncategorized. Tags: emacs, searching.
2 Comments Add your own
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed
1. Interesting Emacs Links - 2009 Week 11 « A Curious Programmer | March 15, 2009 at 5:48 pm
[...] are posts on searching multiple buffers, emacs version control and emacs buttons within the same [...]
2.
vedang | March 17, 2009 at 6:52 am
Thanks dude, this is a big help… may post about this on my own blog (if/when i get time) will surely leave a trackback.