help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: Filtering files in dired while invoking


From: Drew Adams
Subject: RE: Filtering files in dired while invoking
Date: Mon, 30 Aug 2010 13:19:45 -0700

> I was trying to filter the files listed in a dired buffer. Filtering
> with one shell glob works fine, but how do I pass multiple shell globs
> to dired?
> 
> What I 'm looking for is to list files as they would be listed by,
> 
> $ ls -l *.C *.h *.cxx

`C-x d *.[Chc]*' gets you part-way there.

> I couldn't find any reference to this in the info manual. But the
> docstring for dired says this,
> 
>       (dired DIRNAME &optional SWITCHES)
> 
>       .....
>       If DIRNAME is a cons, its first element is
>       taken as the directory name and the rest as an explicit list of
>       files to make directory entries for.
>       .....
> 
> How can I achieve that? Thanks for any suggestions.

The command `dired' does not let you do that.  Its `interactive' spec just reads
a file (directory) name, possibly with wildcards.

But function `dired' does let you do that if you call it from Lisp - you just
need to pass it an explicit list of file names in place of the directory name.

So you could write your own command to do what you want.  The `interactive' spec
would, e.g., read file names (possibly with wildcards) until you enter an empty
name ("") - it would return a list of the names entered.  The body of the
function would just call `dired', passing the list (with a (pseudo-)directory
name prepended to the file names).

However, you can often do what you want to do using marking or omitting instead.
See `dired-omit-mode' in dired-x.el, for example.  If you use Dired+, then you
can combine marking and omitting - omit all of the marked or unmarked files, for
instance.

Marking files is the single most useful thing you can do in Dired.  You can mark
files that match a regexp (`%m'), and so on.  And you can of course mark some
files matching one pattern and then mark some more by matching another pattern.

With one or more 3rd-party features you can also bookmark or save a Dired
listing persistently, so you don't have to remark files from scratch each time.

These links might help:
http://www.emacswiki.org/emacs/DiredPlus
http://www.emacswiki.org/emacs/BookmarkPlus
http://www.emacswiki.org/emacs/Icicles_-_Dired_Enhancements
http://www.emacswiki.org/emacs/CategoryDirectories




reply via email to

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