[Top][All Lists]

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

dired and multi-occur

From: Dirk80
Subject: dired and multi-occur
Date: Fri, 4 Dec 2009 07:30:13 -0800 (PST)


I would like to search a string through multiple files. I like multi-occur a
lot. It would be great if it is possible to combine dired and multi-occur. I
want that multi-occur is applied to all marked files.

Let's say the name of the interactive function to do this is
"my-dired-multi-occur". If the user invokes this function via M-x
my-dired-multi-occur the user shall be asked for a search string. All marked
files shall be searched via dired. If the file does not contain the
search-string it shall be closed again.

I tried to write a function doing this. But I'm an elisp newbie and don't
get it.

(defun my-dired-multi-occur (string)
  "Search string in files marked in dired."
  (interactive "MSearch-String:")
  (require 'dired)
  (multi-occur (mapc 'find-file (dired-get-marked-files)) string))

I get the following result, when I'm invoking this function when I have
opened dired and marked three files: M-x my-dired-multi-occur
Search-String: init

Searched 0 buffers (3 killed); no matches for `init'

My problem seems to be that multi-occur is not getting a list of buffers.
The other problem I have: How can I close all files which do not contain the

Thank you very much for your help in advance.

View this message in context:
Sent from the Emacs - Help mailing list archive at

reply via email to

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