From: "Drew Adams" <drew.adams@oracle.com>
To: "'suvayu ali'" <fatkasuvayu+linux@gmail.com>,
"'Emacs mailing list'" <help-gnu-emacs@gnu.org>
Subject: RE: Filtering files in dired while invoking
Date: Sun, 26 Sep 2010 18:33:15 -0700 [thread overview]
Message-ID: <1E7627AF935349F288114B8AF633CA38@us.oracle.com> (raw)
In-Reply-To: <98DBECF724AA424EA9030AD92CF1F90D@us.oracle.com>
Top-posting on purpose - old mail below provides some context.
FYI - I added this feature to Dired+ for interactive use:
Alternative main commands (for `C-x d' and `C-x 4 d') act the same as usual
except when given a non-positive prefix arg. In that case, you can enter any
number of file or dir names, and a Dired buffer is created for just those files
and dirs. (A prefix of 0 is both non-positive and non-negative, so it also asks
for switches.)
Also, on MS Windows, you can use wildcards in any of the names. I submitted a
patch for this feature (or bug fix) for vanilla Emacs, but it still needs a
minor patch for non-Windows (if anyone is interested in contributing that bit).
HTH.
> From: Drew Adams Sent: Monday, August 30, 2010 11:11 PM
>
> > > > 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).
> >
> > I had a hunch that would be the case. I think I'll try my hand at
> > writing a function like that. Thank you for outlining the basic
> > idea. :) Maybe I can defadvice `dired' to run my function when ever
> > there is a space separated argument, and call regular dired
> > otherwise?
>
> My recommendation would be to not bother with `defadvice' here and
> just write a new command. `dired' already does everything you want
> - it is only its `interactive' spec that does not do what you want.
> Just write a new command `foo' whose `interactive' spec calls
> `read-file-name' in a loop until the input is empty, accumulating
> all the file names read in a list. Pass that list of file names to
> `dired' as its (first) arg. (The list also needs a string at the
> head that names the Dired buffer.) Something like this:
>
> (defun foo (files)
> (interactive
> (list
> (let ((insert-default-directory nil)
> (files ())
> file)
> (while (not (string=
> ""
> (file-name-nondirectory
> (setq file (read-file-name
> "File: " nil nil t)))))
> (push file files))
> files)))
> (dired (cons "A Dir In The Headlights" files)))
>
> Depending on what you need, you might not want to bind
> `insert-default-directory' to nil. That prevents the recorded
> file names from explicitly including the default directory.
>
> If you do bind it to nil, then you don't really need the call to
> `file-name-nondirectory' unless you want to let the user
> enter absolute as well as relative file names.
>
> Yes, this kind of Dired buffer can contain a mix of files
> from different directories. If a file name is not absolute,
> then the value of `default-directory' for the buffer determines
> its directory.
>
> Note too that any of the file names read can in fact be
> directory names.
next prev parent reply other threads:[~2010-09-27 1:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-30 19:26 Filtering files in dired while invoking suvayu ali
2010-08-30 20:19 ` Drew Adams
2010-08-30 23:40 ` suvayu ali
2010-08-31 6:10 ` Drew Adams
2010-08-31 6:18 ` OT (was: Filtering files in dired while invoking) Drew Adams
2010-09-27 1:33 ` Drew Adams [this message]
2010-08-31 12:17 ` Filtering files in dired while invoking Lei Wang
2010-08-31 17:40 ` suvayu ali
[not found] <AANLkTi=3DFkTuuj8U358Sr6_tHUsEK+6yCPoHB32nL6bK_@mail.gmail.com>
2010-08-31 15:28 ` Ehud Karni
2010-08-31 17:33 ` suvayu ali
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1E7627AF935349F288114B8AF633CA38@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=fatkasuvayu+linux@gmail.com \
--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.
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.