unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to search through all buffers?
@ 2003-04-05  2:34 Eric Hanchrow
  2003-04-05  4:11 ` John Paul Wallington
  2003-04-07 18:23 ` Kevin Rodgers
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Hanchrow @ 2003-04-05  2:34 UTC (permalink / raw)



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?

I'm surprised that I haven't found out how to do this through the
manual, or http://www.emacswiki.org.

-- 
Yahoo uses Javascript in a few places, though not many.  I once asked
someone there how this worked out, and he said "they ended up learning
a lot about different browser versions."

    --Paul Graham (http://www.paulgraham.com/road.html)
      Seen on http://www.ccs.neu.edu/home/matthias/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to search through all buffers?
  2003-04-05  2:34 How to search through all buffers? Eric Hanchrow
@ 2003-04-05  4:11 ` John Paul Wallington
  2003-04-05  4:44   ` John Paul Wallington
  2003-04-07 18:23 ` Kevin Rodgers
  1 sibling, 1 reply; 5+ messages in thread
From: John Paul Wallington @ 2003-04-05  4:11 UTC (permalink / raw)


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))

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to search through all buffers?
  2003-04-05  4:11 ` John Paul Wallington
@ 2003-04-05  4:44   ` John Paul Wallington
  2003-04-05  6:11     ` John Russell
  0 siblings, 1 reply; 5+ messages in thread
From: John Paul Wallington @ 2003-04-05  4:44 UTC (permalink / raw)


I misread `occur-read-primary-args'; this is cleaner:

(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))
  (multi-occur (if hidden-bufs-too
		   (buffer-list)
		 (delq nil
		       (mapcar (lambda (buf)
				 (unless (string-match "^ " (buffer-name buf))
				   buf))
			       (buffer-list))))
	       regexp))

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to search through all buffers?
  2003-04-05  4:44   ` John Paul Wallington
@ 2003-04-05  6:11     ` John Russell
  0 siblings, 0 replies; 5+ messages in thread
From: John Russell @ 2003-04-05  6:11 UTC (permalink / raw)


John Paul Wallington <jpw@gnu.org> writes:

> I misread `occur-read-primary-args'; this is cleaner:
> 
> (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))
>   (multi-occur (if hidden-bufs-too
> 		   (buffer-list)
> 		 (delq nil
> 		       (mapcar (lambda (buf)
> 				 (unless (string-match "^ " (buffer-name buf))
> 				   buf))
> 			       (buffer-list))))
> 	       regexp))

Wow, and I had never even heard of occur before.  This function is
great. Thanks. 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to search through all buffers?
  2003-04-05  2:34 How to search through all buffers? Eric Hanchrow
  2003-04-05  4:11 ` John Paul Wallington
@ 2003-04-07 18:23 ` Kevin Rodgers
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2003-04-07 18:23 UTC (permalink / raw)


Eric Hanchrow 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?

<plug type=shameless>

igrep-visited-files: an interactive compiled Lisp function in `igrep'.
(igrep-visited-files PROGRAM EXPRESSION &optional OPTIONS)

*Run `grep` PROGRAM to match EXPRESSION (with optional OPTIONS) on all visited 
files.
See `M-x igrep'.
</plug>


http://www.google.com/groups?&as_umsgid=%3C3D4EAF0E.8010107%40ihs.com%3E

or email me for a newer version.

-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-04-07 18:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-05  2:34 How to search through all buffers? Eric Hanchrow
2003-04-05  4:11 ` John Paul Wallington
2003-04-05  4:44   ` John Paul Wallington
2003-04-05  6:11     ` John Russell
2003-04-07 18:23 ` Kevin Rodgers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).