[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dired and multi-occur
From: |
Andreas Politz |
Subject: |
Re: dired and multi-occur |
Date: |
Fri, 04 Dec 2009 19:21:29 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Dirk80 <dirk@dirkundsari.de> writes:
> Hi,
>
> 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))
You need to use `mapcar'.
>
> 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
> search-string.
>
You can examine the occur buffer afterwards with `occur-next',
`occur-mode-find-occurrence', `marker-buffer' and `buffer-file-name'.
> Thank you very much for your help in advance.
>
> Dirk
-ap