Archive for July 27th, 2008

Searching multiple buffers emacs

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.

2 comments July 27, 2008


Meta

Facets

abstruse Add new tag AOP apt aspect oriented programming assumes knowledge autiobiographical bash scripts bell books clarity code samples configuration console emacs for the benefit of google functional programming graphical design hacks higher-order functions howtos intention revealing programming keyboard links linux note to self opinions parsing patterns philosophising philosophizing programming python random ideas refactoring removing packages short stories succinct svn systems stuff theoretical philosophizing typing work ethic you probably don't want to read this

Archives

Pages

 

July 2008
M T W T F S S
« May   Aug »
 123456
78910111213
14151617181920
21222324252627
28293031