[Top][All Lists]

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

RE: How not to list the .o files in find-dired

From: Drew Adams
Subject: RE: How not to list the .o files in find-dired
Date: Tue, 17 Mar 2009 10:12:10 -0700

> > The find-dired lists all the files recursively under a directory.
> > But i don't want to list the .o files and backup files.
> > How to do that?

`find-dired' is a wrapper for the UNIX-GNU/Linux `find' command. `find' lets you
specify the filenames to match. You should be able to specify something like
`-name *.[^o~]' as the file-name pattern to match (you might need a more complex

I've forgotten what I knew in a former life about `find' (which is a language
unto itself!), but perhaps someone else can give you a precise incantation.

Someone else also mentioned Dired X. It lets you omit files with certain
extensions. But that does not affect what `find' sees; it affects only what
Dired sees. It can perhaps be useful once `find-dired' has gathered files into a
Dired buffer (to let you omit some of them), but I don't think it will help
prevent `find-dired' from finding certain files.

> traverselisp.el do that and you can setup a list of files to ignore in
> `traverse-ignore-files'. You can put a plain name of file, a regexp
> matching file-name, or an extension of file in this list.
> You can match also only certain types of files or ext files.
> Traverselisp have also an anything extension that list files 
> recursively in current-dir (with same options).
> See in emacswiki: traverselisp.el anything-traverse.el Anything

You can also use Icicles to do what you want. Use `icicle-locate-file'. Type the
file-name pattern you want to match (you can use a regexp). You can match any
parts of the file names, including directory components.

To then eliminate .o and backup files from the matching files, hit `M-SPC' to
also match another pattern. For the second pattern, type `\.o$' (to get just the
.o files), then hit `C-~' to remove those (the .o files) from the list of
candidates. Similarly, to eliminate backup files from the list (the backup
pattern you use depends on your backup naming convention).

You can use `M-SPC' for any number of patterns to match the files you need - use
`C-~' to match negatively. Think of `M-SPC' as set interesection and `C-~' as
set complement.

This gives you a complete list of all files under some directory that match your
input pattern, except for the .o and backup files. The names in this list are
candidates for completion. You can act on one or more of them immediately (using
`RET' or `C-RET'), to open it, or you can save the list for later use
(persistently, if you like).

You can also open Dired on the files in the list. That will give you just what
you asked for: Dired for all and only the files you want under some directory,
regardless of which subdirectories they are from. And, if you saved the list
persistently (see above), then you can later reopen Dired on just those files in
any subsequent Emacs session.


reply via email to

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