From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.help Subject: RE: Filtering files in dired while invoking Date: Sun, 26 Sep 2010 18:33:15 -0700 Message-ID: <1E7627AF935349F288114B8AF633CA38@us.oracle.com> References: <98DBECF724AA424EA9030AD92CF1F90D@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1285551228 13310 80.91.229.12 (27 Sep 2010 01:33:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 27 Sep 2010 01:33:48 +0000 (UTC) To: "'suvayu ali'" , "'Emacs mailing list'" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 27 03:33:46 2010 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.69) (envelope-from ) id 1P02bA-000812-Uh for geh-help-gnu-emacs@m.gmane.org; Mon, 27 Sep 2010 03:33:45 +0200 Original-Received: from localhost ([127.0.0.1]:32956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P02bA-0007Wf-8H for geh-help-gnu-emacs@m.gmane.org; Sun, 26 Sep 2010 21:33:44 -0400 Original-Received: from [140.186.70.92] (port=36299 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P02am-0007Wa-NA for help-gnu-emacs@gnu.org; Sun, 26 Sep 2010 21:33:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P02al-0007xZ-DF for help-gnu-emacs@gnu.org; Sun, 26 Sep 2010 21:33:20 -0400 Original-Received: from rcsinet10.oracle.com ([148.87.113.121]:57587) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P02al-0007xN-7p for help-gnu-emacs@gnu.org; Sun, 26 Sep 2010 21:33:19 -0400 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id o8R1XGsr003418 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 27 Sep 2010 01:33:17 GMT Original-Received: from acsmt355.oracle.com (acsmt355.oracle.com [141.146.40.155]) by acsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o8R0iUcs008706 for ; Mon, 27 Sep 2010 01:33:15 GMT Original-Received: from abhmt007.oracle.com by acsmt354.oracle.com with ESMTP id 631306281285551187; Sun, 26 Sep 2010 18:33:07 -0700 Original-Received: from dradamslap1 (/10.159.219.230) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 26 Sep 2010 18:33:07 -0700 X-Mailer: Microsoft Office Outlook 11 In-Reply-To: <98DBECF724AA424EA9030AD92CF1F90D@us.oracle.com> Thread-Index: ActInNZwj2YYA0dlTT2flb5Kqud1hgAMAm0gBUVwSlA= X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994 X-detected-operating-system: by eggs.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:75019 Archived-At: 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.