all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* dired and multi-occur
@ 2009-12-04 15:30 Dirk80
  2009-12-04 18:21 ` Andreas Politz
  2009-12-05  7:59 ` Kevin Rodgers
  0 siblings, 2 replies; 6+ messages in thread
From: Dirk80 @ 2009-12-04 15:30 UTC (permalink / raw)
  To: Help-gnu-emacs


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

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.

Thank you very much for your help in advance.

Dirk
-- 
View this message in context: http://old.nabble.com/dired-and-multi-occur-tp26635922p26635922.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





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

* Re: dired and multi-occur
  2009-12-04 15:30 dired and multi-occur Dirk80
@ 2009-12-04 18:21 ` Andreas Politz
  2009-12-09  9:14   ` Dirk80
  2009-12-05  7:59 ` Kevin Rodgers
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Politz @ 2009-12-04 18:21 UTC (permalink / raw)
  To: help-gnu-emacs

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





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

* Re: dired and multi-occur
  2009-12-04 15:30 dired and multi-occur Dirk80
  2009-12-04 18:21 ` Andreas Politz
@ 2009-12-05  7:59 ` Kevin Rodgers
  2009-12-05 10:20   ` Thierry Volpiatto
  1 sibling, 1 reply; 6+ messages in thread
From: Kevin Rodgers @ 2009-12-05  7:59 UTC (permalink / raw)
  To: help-gnu-emacs

Dirk80 wrote:
> 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.

Why not:

,----[ C-h k A ]
| A runs the command dired-do-search
|   which is an interactive autoloaded Lisp function in `dired-aux'.
| It is bound to A, <menu-bar> <operate> <search>.
| (dired-do-search regexp)
|
| Search through all marked files for a match for regexp.
| Stops when a match is found.
| To continue searching for next match, use command M-,.
`----

-- 
Kevin Rodgers
Denver, Colorado, USA





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

* Re: dired and multi-occur
  2009-12-05  7:59 ` Kevin Rodgers
@ 2009-12-05 10:20   ` Thierry Volpiatto
  0 siblings, 0 replies; 6+ messages in thread
From: Thierry Volpiatto @ 2009-12-05 10:20 UTC (permalink / raw)
  To: help-gnu-emacs

Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:

> Dirk80 wrote:
>> 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.
>
> Why not:
>
> ,----[ C-h k A ]
> | A runs the command dired-do-search
> |   which is an interactive autoloaded Lisp function in `dired-aux'.
> | It is bound to A, <menu-bar> <operate> <search>.
> | (dired-do-search regexp)
> |
> | Search through all marked files for a match for regexp.
> | Stops when a match is found.
> | To continue searching for next match, use command M-,.
> `----

Also, traverselisp.el does all that and anything-traverse.el does that
incrementally. See:
http://mercurial.intuxication.org/hg/traverselisp

-- 
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France





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

* Re: dired and multi-occur
       [not found] <mailman.12194.1259940624.2239.help-gnu-emacs@gnu.org>
@ 2009-12-05 14:03 ` Michael Heerdegen
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2009-12-05 14:03 UTC (permalink / raw)
  To: help-gnu-emacs

color-moccur.el has a `dired-do-moccur' command.


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

* Re: dired and multi-occur
  2009-12-04 18:21 ` Andreas Politz
@ 2009-12-09  9:14   ` Dirk80
  0 siblings, 0 replies; 6+ messages in thread
From: Dirk80 @ 2009-12-09  9:14 UTC (permalink / raw)
  To: Help-gnu-emacs



Andreas Politz wrote:
> 
> You need to use `mapcar'.
> 

Hi,

thank you very much. `mapcar' is the solution. 

Here the code:
(defun my-dired-multi-occur (string)
  "Search string in files marked by dired."
  (interactive "MList lines matching regexp: ")
  (require 'dired)
  (multi-occur (mapcar 'find-file (dired-get-marked-files)) string))

And thank you for the other answers. 
`dired-do-moccur' is also working fine.

Greetings,
Dirk
-- 
View this message in context: http://old.nabble.com/dired-and-multi-occur-tp26635922p26707171.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





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

end of thread, other threads:[~2009-12-09  9:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-04 15:30 dired and multi-occur Dirk80
2009-12-04 18:21 ` Andreas Politz
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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.