Skip to content

Commit f5e3c2c

Browse files
committed
Add a new user option 'ido-big-directories'.
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.
1 parent 74f54af commit f5e3c2c

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

etc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,11 @@ current and the previous or the next line, as before.
410410
*** New commands doc-view-presentation and doc-view-fit-window-to-page
411411
*** Added support for password-protected PDF files
412412

413+
** Ido
414+
*** New user option 'ido-big-directories' to mark directories whose
415+
names match certain regular expressions as big. Ido won't attempt to
416+
list the contents of such directories when completing file names.
417+
413418
** map.el
414419
*** Now also understands plists.
415420
*** Now defined via generic functions that can be extended via 'cl-defmethod'.

lisp/ido.el

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,14 @@ not provide the normal completion. To show the completions, use \\[ido-toggle-i
735735
(integer :tag "Size in bytes" 30000))
736736
:group 'ido)
737737

738+
(defcustom ido-big-directories nil
739+
"List of directory pattern strings that should be considered big.
740+
Ido won't attempt to list the contents of directories matching
741+
any of these regular expressions when completing file names."
742+
:type '(repeat regexp)
743+
:group 'ido
744+
:version "27.1")
745+
738746
(defcustom ido-rotate-file-list-default nil
739747
"Non-nil means that Ido will always rotate file list to get default in front."
740748
:type 'boolean
@@ -1743,13 +1751,16 @@ is enabled then some keybindings are changed in the keymap."
17431751
;; Return t if dir is a directory, but too big to show
17441752
;; Do not check for non-readable directories via tramp, as this causes a premature
17451753
;; connect on incomplete tramp paths (after entering just method:).
1746-
(let ((ido-enable-tramp-completion nil))
1747-
(and (numberp ido-max-directory-size)
1748-
(ido-final-slash dir)
1749-
(not (ido-is-unc-host dir))
1750-
(file-directory-p dir)
1751-
(> (file-attribute-size (file-attributes (file-truename dir)))
1752-
ido-max-directory-size))))
1754+
(let ((ido-enable-tramp-completion nil)
1755+
(case-fold-search nil))
1756+
(or (seq-some (lambda (regexp) (string-match-p regexp dir))
1757+
ido-big-directories)
1758+
(and (numberp ido-max-directory-size)
1759+
(ido-final-slash dir)
1760+
(not (ido-is-unc-host dir))
1761+
(file-directory-p dir)
1762+
(> (file-attribute-size (file-attributes (file-truename dir)))
1763+
ido-max-directory-size)))))
17531764

17541765
(defun ido-set-current-directory (dir &optional subdir no-merge)
17551766
;; Set ido's current directory to DIR or DIR/SUBDIR

test/lisp/ido-tests.el

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
;;; Code:
2727

28+
(require 'ido)
29+
2830
(ert-deftest ido-tests--other-window-frame ()
2931
"Verifies that Bug#26360 is fixed."
3032
(should-not ido-mode)
@@ -44,4 +46,9 @@
4446
(should (commandp #'ido-display-buffer-other-frame)))
4547
(ido-mode 0)))
4648

49+
(ert-deftest ido-directory-too-big-p ()
50+
(should-not (ido-directory-too-big-p "/some/dir/"))
51+
(let ((ido-big-directories (cons (rx "me/di") ido-big-directories)))
52+
(should (ido-directory-too-big-p "/some/dir/"))))
53+
4754
;;; ido-tests.el ends here

0 commit comments

Comments
 (0)