unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13003: Ido wide-find-file fixes
@ 2012-11-26 15:48 Eyal Lotem
  2013-06-12  7:28 ` Glenn Morris
  0 siblings, 1 reply; 2+ messages in thread
From: Eyal Lotem @ 2012-11-26 15:48 UTC (permalink / raw)
  To: 13003


[-- Attachment #1.1: Type: text/plain, Size: 388 bytes --]

Currently, when you use alt-w to do a wide-find-file under current selected
dir (which uses "find" under the hood), it incorrectly uses "-name"
exclusively, even with case fold, which should use "-iname".

Additionally, it does not filter the results of find like it filters other
file results (according to the ignore filenames).

Attached are two patches to fix the behavior.

-- 
Eyal

[-- Attachment #1.2: Type: text/html, Size: 500 bytes --]

[-- Attachment #2: 0001-ido.el-Wide-find-file-should-ignore-files-like-the-r.patch --]
[-- Type: application/octet-stream, Size: 2296 bytes --]

From f5eda0ed1c1f0139f528c67a6b7a8d97b10e8042 Mon Sep 17 00:00:00 2001
From: Eyal Lotem <eyal.lotem@gmail.com>
Date: Mon, 26 Nov 2012 17:21:28 +0200
Subject: [PATCH 1/2] ido.el: Wide-find-file should ignore files like the rest

---
 lisp/ido.el |   31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/lisp/ido.el b/lisp/ido.el
index f4f9c27..3baf57f 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -3268,14 +3268,15 @@ for first matching file."
 (defun ido-wide-find-dirs-or-files (dir file &optional prefix finddir)
   ;; As ido-run-find-command, but returns a list of cons pairs ("file" . "dir")
   (let ((filenames
-	 (split-string
-	  (shell-command-to-string
-	   (concat "find "
-		   (shell-quote-argument dir)
-		   " -name "
-		   (shell-quote-argument
-		    (concat (if prefix "" "*") file "*"))
-		   " -type " (if finddir "d" "f") " -print"))))
+         (delete-ignored-files
+          (split-string
+           (shell-command-to-string
+            (concat "find "
+                    (shell-quote-argument dir)
+                    " -name "
+                    (shell-quote-argument
+                     (concat (if prefix "" "*") file "*"))
+                    " -type " (if finddir "d" "f") " -print")))))
 	filename d f
 	res)
     (while filenames
@@ -3564,18 +3565,20 @@ This is to make them appear as if they were \"virtual buffers\"."
 	(if cached
 	    (setq ido-dir-file-cache (delq cached ido-dir-file-cache))))))
 
+(defun delete-ignored-files (files)
+  (delete-if
+   (lambda (name) (ido-ignore-item-p name ido-ignore-files t))
+   files))
 
 (defun ido-make-file-list-1 (dir &optional merged)
   ;; Return list of non-ignored files in DIR
   ;; If MERGED is non-nil, each file is cons'ed with DIR
   (and (or (ido-is-tramp-root dir) (ido-is-unc-root dir)
 	   (file-directory-p dir))
-       (delq nil
-	     (mapcar
-	      (lambda (name)
-		(if (not (ido-ignore-item-p name ido-ignore-files t))
-		    (if merged (cons name dir) name)))
-	      (ido-file-name-all-completions dir)))))
+       (mapcar
+	(lambda (name) (if merged (cons name dir) name))
+	(delete-ignored-files
+	 (ido-file-name-all-completions dir)))))
 
 (defun ido-make-file-list (default)
   ;; Return the current list of files.
-- 
1.7.10.4


[-- Attachment #3: 0002-ido.el-wide-find-file-Use-iname-rather-than-name-if-.patch --]
[-- Type: application/octet-stream, Size: 1408 bytes --]

From ea7817036a2b2c2357ccccadcca8540474eb4695 Mon Sep 17 00:00:00 2001
From: Eyal Lotem <eyal.lotem@gmail.com>
Date: Mon, 26 Nov 2012 17:21:45 +0200
Subject: [PATCH 2/2] ido.el: wide-find-file: Use -iname rather than -name if
 ido-case-fold is enabled

---
 lisp/ido.el |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lisp/ido.el b/lisp/ido.el
index 3baf57f..beb7c06 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -3268,15 +3268,15 @@ for first matching file."
 (defun ido-wide-find-dirs-or-files (dir file &optional prefix finddir)
   ;; As ido-run-find-command, but returns a list of cons pairs ("file" . "dir")
   (let ((filenames
-         (delete-ignored-files
-          (split-string
-           (shell-command-to-string
-            (concat "find "
-                    (shell-quote-argument dir)
-                    " -name "
-                    (shell-quote-argument
-                     (concat (if prefix "" "*") file "*"))
-                    " -type " (if finddir "d" "f") " -print")))))
+	 (delete-ignored-files
+	  (split-string
+	   (shell-command-to-string
+	    (concat "find "
+		    (shell-quote-argument dir)
+		    (if ido-case-fold " -iname " " -name ")
+		    (shell-quote-argument
+		     (concat (if prefix "" "*") file "*"))
+		    " -type " (if finddir "d" "f") " -print")))))
 	filename d f
 	res)
     (while filenames
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#13003: Ido wide-find-file fixes
  2012-11-26 15:48 bug#13003: Ido wide-find-file fixes Eyal Lotem
@ 2013-06-12  7:28 ` Glenn Morris
  0 siblings, 0 replies; 2+ messages in thread
From: Glenn Morris @ 2013-06-12  7:28 UTC (permalink / raw)
  To: 13003-done

Version: 24.4

Thanks; applied w. namespace tweak.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-06-12  7:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-26 15:48 bug#13003: Ido wide-find-file fixes Eyal Lotem
2013-06-12  7:28 ` Glenn Morris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).