help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to search through all buffers?


From: John Paul Wallington
Subject: Re: How to search through all buffers?
Date: Sat, 05 Apr 2003 05:11:47 +0100
User-agent: Gnus/5.090017 (Oort Gnus v0.17) Emacs/21.3.50 (powerpc-unknown-linux-gnu)

Eric Hanchrow <offby1@blarg.net> wrote:

> I'd like to find all the occurrences of a particular word in all my
> Emacs buffers, but cannot think of a way to do it short of writing my
> own Elisp.  Is there in fact a way?

With Emacs CVS HEAD (which you appear to be using) you can mark your
buffers in Ibuffer then press O.  Or use the `multi-occur' or
`multi-occur-by-filename-regexp' commands.  If the interactivity is
tiresome, how about something like this (lightly tested):

(defun hanchrow-all-encompassing-occur (regexp &optional hidden-bufs-too)
  "Show all lines in all visible buffers containing a match for REGEXP.
With prefix arg HIDDEN-BUFS-TOO, show lines matching in all buffers."
  (interactive (occur-read-primary-args))
  (if (interactive-p)
      (setq hidden-bufs-too current-prefix-arg))
  (multi-occur (if hidden-bufs-too
                   (buffer-list)
                 (delq nil
                       (mapcar (lambda (buf)
                                 (unless (string-match "^ " (buffer-name buf))
                                   buf))
                               (buffer-list))))
               regexp))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]