aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Stephani2019-04-12 14:23:01 +0200
committerPhilipp Stephani2019-04-19 10:31:02 +0200
commitf5e3c2cc9820a4f7f536a29836cdde6f65230bd3 (patch)
tree708cffe53e4e7666a365eee964ae49892342f091
parent74f54af2b9048cb1ea7a051c9efe079eaaeb4697 (diff)
downloademacs-f5e3c2cc9820a4f7f536a29836cdde6f65230bd3.tar.gz
emacs-f5e3c2cc9820a4f7f536a29836cdde6f65230bd3.zip
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.
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ido.el25
-rw-r--r--test/lisp/ido-tests.el7
3 files changed, 30 insertions, 7 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 5e5d942d89a..3e3454bd939 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -410,6 +410,11 @@ current and the previous or the next line, as before.
410*** New commands doc-view-presentation and doc-view-fit-window-to-page 410*** New commands doc-view-presentation and doc-view-fit-window-to-page
411*** Added support for password-protected PDF files 411*** Added support for password-protected PDF files
412 412
413** Ido
414*** New user option 'ido-big-directories' to mark directories whose
415names match certain regular expressions as big. Ido won't attempt to
416list the contents of such directories when completing file names.
417
413** map.el 418** map.el
414*** Now also understands plists. 419*** Now also understands plists.
415*** Now defined via generic functions that can be extended via 'cl-defmethod'. 420*** Now defined via generic functions that can be extended via 'cl-defmethod'.
diff --git a/lisp/ido.el b/lisp/ido.el
index 08540145815..1a3a384ae6b 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -735,6 +735,14 @@ not provide the normal completion. To show the completions, use \\[ido-toggle-i
735 (integer :tag "Size in bytes" 30000)) 735 (integer :tag "Size in bytes" 30000))
736 :group 'ido) 736 :group 'ido)
737 737
738(defcustom ido-big-directories nil
739 "List of directory pattern strings that should be considered big.
740Ido won't attempt to list the contents of directories matching
741any of these regular expressions when completing file names."
742 :type '(repeat regexp)
743 :group 'ido
744 :version "27.1")
745
738(defcustom ido-rotate-file-list-default nil 746(defcustom ido-rotate-file-list-default nil
739 "Non-nil means that Ido will always rotate file list to get default in front." 747 "Non-nil means that Ido will always rotate file list to get default in front."
740 :type 'boolean 748 :type 'boolean
@@ -1743,13 +1751,16 @@ is enabled then some keybindings are changed in the keymap."
1743 ;; Return t if dir is a directory, but too big to show 1751 ;; Return t if dir is a directory, but too big to show
1744 ;; Do not check for non-readable directories via tramp, as this causes a premature 1752 ;; Do not check for non-readable directories via tramp, as this causes a premature
1745 ;; connect on incomplete tramp paths (after entering just method:). 1753 ;; connect on incomplete tramp paths (after entering just method:).
1746 (let ((ido-enable-tramp-completion nil)) 1754 (let ((ido-enable-tramp-completion nil)
1747 (and (numberp ido-max-directory-size) 1755 (case-fold-search nil))
1748 (ido-final-slash dir) 1756 (or (seq-some (lambda (regexp) (string-match-p regexp dir))
1749 (not (ido-is-unc-host dir)) 1757 ido-big-directories)
1750 (file-directory-p dir) 1758 (and (numberp ido-max-directory-size)
1751 (> (file-attribute-size (file-attributes (file-truename dir))) 1759 (ido-final-slash dir)
1752 ido-max-directory-size)))) 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)))))
1753 1764
1754(defun ido-set-current-directory (dir &optional subdir no-merge) 1765(defun ido-set-current-directory (dir &optional subdir no-merge)
1755 ;; Set ido's current directory to DIR or DIR/SUBDIR 1766 ;; Set ido's current directory to DIR or DIR/SUBDIR
diff --git a/test/lisp/ido-tests.el b/test/lisp/ido-tests.el
index cb8f1d63069..c9736eb3ecf 100644
--- a/test/lisp/ido-tests.el
+++ b/test/lisp/ido-tests.el
@@ -25,6 +25,8 @@
25 25
26;;; Code: 26;;; Code:
27 27
28(require 'ido)
29
28(ert-deftest ido-tests--other-window-frame () 30(ert-deftest ido-tests--other-window-frame ()
29 "Verifies that Bug#26360 is fixed." 31 "Verifies that Bug#26360 is fixed."
30 (should-not ido-mode) 32 (should-not ido-mode)
@@ -44,4 +46,9 @@
44 (should (commandp #'ido-display-buffer-other-frame))) 46 (should (commandp #'ido-display-buffer-other-frame)))
45 (ido-mode 0))) 47 (ido-mode 0)))
46 48
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
47;;; ido-tests.el ends here 54;;; ido-tests.el ends here