From: Andreas Politz <politza@fh-trier.de>
To: help-gnu-emacs@gnu.org
Subject: Re: dired and multi-occur
Date: Fri, 04 Dec 2009 19:21:29 +0100 [thread overview]
Message-ID: <871vja8us6.fsf@fh-trier.de> (raw)
In-Reply-To: 26635922.post@talk.nabble.com
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
next prev parent reply other threads:[~2009-12-04 18:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-04 15:30 dired and multi-occur Dirk80
2009-12-04 18:21 ` Andreas Politz [this message]
2009-12-09 9:14 ` Dirk80
2009-12-05 7:59 ` Kevin Rodgers
2009-12-05 10:20 ` Thierry Volpiatto
[not found] <mailman.12194.1259940624.2239.help-gnu-emacs@gnu.org>
2009-12-05 14:03 ` Michael Heerdegen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871vja8us6.fsf@fh-trier.de \
--to=politza@fh-trier.de \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).