From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.help Subject: Re: dired and multi-occur Date: Fri, 04 Dec 2009 19:21:29 +0100 Message-ID: <871vja8us6.fsf@fh-trier.de> References: <26635922.post@talk.nabble.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1259951066 12242 80.91.229.12 (4 Dec 2009 18:24:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Dec 2009 18:24:26 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Dec 04 19:24:20 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NGcpF-0001U3-Ud for geh-help-gnu-emacs@m.gmane.org; Fri, 04 Dec 2009 19:24:18 +0100 Original-Received: from localhost ([127.0.0.1]:41997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGcpF-00025h-JK for geh-help-gnu-emacs@m.gmane.org; Fri, 04 Dec 2009 13:24:17 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NGcn4-0008Ig-UE for help-gnu-emacs@gnu.org; Fri, 04 Dec 2009 13:22:02 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NGcn0-0008GO-SQ for help-gnu-emacs@gnu.org; Fri, 04 Dec 2009 13:22:02 -0500 Original-Received: from [199.232.76.173] (port=36576 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NGcn0-0008GG-FB for help-gnu-emacs@gnu.org; Fri, 04 Dec 2009 13:21:58 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:39296) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NGcn0-0006FS-1E for help-gnu-emacs@gnu.org; Fri, 04 Dec 2009 13:21:58 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1NGcmu-0000X1-Cl for help-gnu-emacs@gnu.org; Fri, 04 Dec 2009 19:21:52 +0100 Original-Received: from dslb-084-059-217-176.pools.arcor-ip.net ([84.59.217.176]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 04 Dec 2009 19:21:52 +0100 Original-Received: from politza by dslb-084-059-217-176.pools.arcor-ip.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 04 Dec 2009 19:21:52 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 47 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dslb-084-059-217-176.pools.arcor-ip.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:JPBV322DUKP1INgtL+6d2iKy8hU= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:70398 Archived-At: Dirk80 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