]> git.eshelyaron.com Git - emacs.git/commitdiff
Add a new user option 'ido-big-directories'.
authorPhilipp Stephani <p.stephani2@gmail.com>
Fri, 12 Apr 2019 12:23:01 +0000 (14:23 +0200)
committerPhilipp Stephani <phst@google.com>
Fri, 19 Apr 2019 08:31:02 +0000 (10:31 +0200)
This provides an alternative to 'ido-max-directory-size', for
directories that are statically known to be too big for Ido
completion.

* lisp/ido.el (ido-big-directories): New user option.
(ido-directory-too-big-p): Use it.

* test/lisp/ido-tests.el (ido-directory-too-big-p): New unit test.

etc/NEWS
lisp/ido.el
test/lisp/ido-tests.el

index 5e5d942d89a2193f77ce52612a36dc69a0731410..3e3454bd939bc79b5c53aaca95be7cefb757de5f 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -410,6 +410,11 @@ current and the previous or the next line, as before.
 *** New commands doc-view-presentation and doc-view-fit-window-to-page
 *** Added support for password-protected PDF files
 
+** Ido
+*** New user option 'ido-big-directories' to mark directories whose
+names match certain regular expressions as big.  Ido won't attempt to
+list the contents of such directories when completing file names.
+
 ** map.el
 *** Now also understands plists.
 *** Now defined via generic functions that can be extended via 'cl-defmethod'.
index 08540145815faaf7615e6b6f392d05737601fc95..1a3a384ae6bbdd0de479436ecc79b29e1d9f1a91 100644 (file)
@@ -735,6 +735,14 @@ not provide the normal completion.  To show the completions, use \\[ido-toggle-i
                 (integer :tag "Size in bytes" 30000))
   :group 'ido)
 
+(defcustom ido-big-directories nil
+  "List of directory pattern strings that should be considered big.
+Ido won't attempt to list the contents of directories matching
+any of these regular expressions when completing file names."
+  :type '(repeat regexp)
+  :group 'ido
+  :version "27.1")
+
 (defcustom ido-rotate-file-list-default nil
   "Non-nil means that Ido will always rotate file list to get default in front."
   :type 'boolean
@@ -1743,13 +1751,16 @@ is enabled then some keybindings are changed in the keymap."
   ;; Return t if dir is a directory, but too big to show
   ;; Do not check for non-readable directories via tramp, as this causes a premature
   ;; connect on incomplete tramp paths (after entering just method:).
-  (let ((ido-enable-tramp-completion nil))
-    (and (numberp ido-max-directory-size)
-        (ido-final-slash dir)
-        (not (ido-is-unc-host dir))
-        (file-directory-p dir)
-        (> (file-attribute-size (file-attributes (file-truename dir)))
-           ido-max-directory-size))))
+  (let ((ido-enable-tramp-completion nil)
+        (case-fold-search nil))
+    (or (seq-some (lambda (regexp) (string-match-p regexp dir))
+                  ido-big-directories)
+        (and (numberp ido-max-directory-size)
+            (ido-final-slash dir)
+            (not (ido-is-unc-host dir))
+            (file-directory-p dir)
+            (> (file-attribute-size (file-attributes (file-truename dir)))
+               ido-max-directory-size)))))
 
 (defun ido-set-current-directory (dir &optional subdir no-merge)
   ;; Set ido's current directory to DIR or DIR/SUBDIR
index cb8f1d63069a07fc000804279985a43d0e07999e..c9736eb3ecfd267631ded4f3d0a3cbe273a199fb 100644 (file)
@@ -25,6 +25,8 @@
 
 ;;; Code:
 
+(require 'ido)
+
 (ert-deftest ido-tests--other-window-frame ()
   "Verifies that Bug#26360 is fixed."
   (should-not ido-mode)
@@ -44,4 +46,9 @@
         (should (commandp #'ido-display-buffer-other-frame)))
     (ido-mode 0)))
 
+(ert-deftest ido-directory-too-big-p ()
+  (should-not (ido-directory-too-big-p "/some/dir/"))
+  (let ((ido-big-directories (cons (rx "me/di") ido-big-directories)))
+    (should (ido-directory-too-big-p "/some/dir/"))))
+
 ;;; ido-tests.el ends here