From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: [PATCH] allow wildcards in file names of cons arg to `dired' Date: Sun, 26 Sep 2010 11:03:45 -0700 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_001D_01CB5D6A.7D4D0FF0" X-Trace: dough.gmane.org 1285524316 18280 80.91.229.12 (26 Sep 2010 18:05:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 26 Sep 2010 18:05:16 +0000 (UTC) To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 26 20:05:13 2010 Return-path: Envelope-to: ged-emacs-devel@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 1Ozvb3-0006jz-4u for ged-emacs-devel@m.gmane.org; Sun, 26 Sep 2010 20:05:09 +0200 Original-Received: from localhost ([127.0.0.1]:60446 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ozvb2-0003UL-9W for ged-emacs-devel@m.gmane.org; Sun, 26 Sep 2010 14:05:08 -0400 Original-Received: from [140.186.70.92] (port=55806 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ozvas-0003SJ-49 for emacs-devel@gnu.org; Sun, 26 Sep 2010 14:04:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ozvaq-0003tS-OG for emacs-devel@gnu.org; Sun, 26 Sep 2010 14:04:57 -0400 Original-Received: from rcsinet10.oracle.com ([148.87.113.121]:64916) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ozvaq-0003tK-Hd for emacs-devel@gnu.org; Sun, 26 Sep 2010 14:04:56 -0400 Original-Received: from rcsinet15.oracle.com (rcsinet15.oracle.com [148.87.113.117]) by rcsinet10.oracle.com (Switch-3.4.2/Switch-3.4.2) with ESMTP id o8QI4rh7016673 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 26 Sep 2010 18:04:55 GMT Original-Received: from acsmt355.oracle.com (acsmt355.oracle.com [141.146.40.155]) by rcsinet15.oracle.com (Switch-3.4.2/Switch-3.4.1) with ESMTP id o8QHudYq014159 for ; Sun, 26 Sep 2010 18:04:53 GMT Original-Received: from abhmt005.oracle.com by acsmt354.oracle.com with ESMTP id 637744611285524221; Sun, 26 Sep 2010 11:03:41 -0700 Original-Received: from dradamslap1 (/10.159.222.156) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 26 Sep 2010 11:03:41 -0700 X-Mailer: Microsoft Office Outlook 11 Thread-Index: ActdpSkokPBPiitcSQOhuJ/tQuJWzA== 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: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:130924 Archived-At: This is a multi-part message in MIME format. ------=_NextPart_000_001D_01CB5D6A.7D4D0FF0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit You can pass a cons arg to `dired', to have it create a Dired buffer that shows only the files in the cdr of that cons (and with buffer name the car of the cons). Very useful (and hardly documented). But currently those file names must be literal names - no wildcards. For example, try this: (dired '("TTTT" "111.el" "b*.el")), assuming there is a file 111.el and some file(s) matching b*.el (but no file with name "b*.el", i.e. with a literal `*' in the name). An error is raised, because `dired' treats `b*.el' as a literal file name instead of globbing it. It would be nice to show a Dired buffer named "TTTT" listing file 111.el and all of the files whose names match b*.el. See also bug #7027. It reports only that the error msg shown when a wildcard is used this way is a bad msg: It should say "b*.el: doesn't exist or is inaccessible" (just as it does for other non-existent files), but instead it barfs: "(wrong-type-arg stringp nil)". But why shouldn't we allow wildcards in the file names of the cons, and not just in a directory name? That can be very handy. Attached are tiny patches for `dired.el' and `ls-lisp.el' that implement this feature for MS Windows (`ls-lisp.el' defines `insert-directory' on Windows). To implement this fully on non-Windows platforms, some changes would no doubt also be needed to the version of `insert-directory' in `files.el'. I cannot do that part, but I hope that someone else can and will. ------=_NextPart_000_001D_01CB5D6A.7D4D0FF0 Content-Type: application/octet-stream; name="dired-2010-09-26.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="dired-2010-09-26.patch" diff -cw dired.el dired-patched-2010-09-26.el=0A= *** dired.el Sun Sep 26 09:57:16 2010=0A= --- dired-patched-2010-09-26.el Sun Sep 26 10:05:44 2010=0A= ***************=0A= *** 935,943 ****=0A= (directory-file-name (file-name-directory dir))))=0A= (error "Directory %s inaccessible or nonexistent" dir)=0A= ;; Else treat it as a wildcard spec=0A= ! ;; unless we have an explicit list of files.=0A= ! (dired-insert-directory dir dired-actual-switches=0A= ! file-list (not file-list) t)))))=0A= =0A= (defun dired-align-file (beg end)=0A= "Align the fields of a file to the ones of surrounding lines.=0A= --- 935,941 ----=0A= (directory-file-name (file-name-directory dir))))=0A= (error "Directory %s inaccessible or nonexistent" dir)=0A= ;; Else treat it as a wildcard spec=0A= ! (dired-insert-directory dir dired-actual-switches file-list t t)))))=0A= =0A= (defun dired-align-file (beg end)=0A= "Align the fields of a file to the ones of surrounding lines.=0A= ***************=0A= *** 1065,1071 ****=0A= (if file-list=0A= (dolist (f file-list)=0A= (let ((beg (point)))=0A= ! (insert-directory f switches nil nil)=0A= ;; Re-align fields, if necessary.=0A= (dired-align-file beg (point))))=0A= (insert-directory dir switches wildcard (not wildcard)))=0A= --- 1063,1070 ----=0A= (if file-list=0A= (dolist (f file-list)=0A= (let ((beg (point)))=0A= ! ;; Compute wildcard arg for this file.=0A= ! (insert-directory f switches (string-match "[[?*]" f) nil)=0A= ;; Re-align fields, if necessary.=0A= (dired-align-file beg (point))))=0A= (insert-directory dir switches wildcard (not wildcard)))=0A= =0A= Diff finished. Sun Sep 26 10:19:17 2010=0A= ------=_NextPart_000_001D_01CB5D6A.7D4D0FF0 Content-Type: application/octet-stream; name="ls-lisp-2010-09-26.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ls-lisp-2010-09-26.patch" diff -cw ls-lisp.el ls-lisp-patched-2010-09-26.el=0A= *** ls-lisp.el Sun Sep 26 09:58:38 2010=0A= --- ls-lisp-patched-2010-09-26.el Sun Sep 26 10:00:54 2010=0A= ***************=0A= *** 294,300 ****=0A= regexp*. FULL-DIRECTORY-P means file is a directory and SWITCHES does=0A= not contain `d', so that a full listing is expected."=0A= (if (or wildcard-regexp full-directory-p)=0A= ! (let* ((dir (file-name-as-directory file))=0A= (default-directory dir) ; so that file-attributes works=0A= (file-alist=0A= (directory-files-and-attributes dir nil wildcard-regexp t=0A= --- 294,300 ----=0A= regexp*. FULL-DIRECTORY-P means file is a directory and SWITCHES does=0A= not contain `d', so that a full listing is expected."=0A= (if (or wildcard-regexp full-directory-p)=0A= ! (let* ((dir (if file (file-name-as-directory file) = default-directory))=0A= (default-directory dir) ; so that file-attributes works=0A= (file-alist=0A= (directory-files-and-attributes dir nil wildcard-regexp t=0A= =0A= Diff finished. Sun Sep 26 10:22:04 2010=0A= ------=_NextPart_000_001D_01CB5D6A.7D4D0FF0--