From: Philipp Stephani <p.stephani2@gmail.com>
To: eliz@gnu.org, emacs-devel@gnu.org
Cc: Philipp Stephani <p.stephani2@gmail.com>
Subject: [PATCH] Add a new user option 'ido-big-directories'.
Date: Wed, 17 Apr 2019 20:31:52 +0200 [thread overview]
Message-ID: <20190417183152.42323-1-phst@google.com> (raw)
In-Reply-To: <CAArVCkQTYbN3VfBAbo-3jWuGp0=oRfME9+bZMMuRJGR7ueYSFw@mail.gmail.com>
From: Philipp Stephani <p.stephani2@gmail.com>
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 | 5 +++++
lisp/ido.el | 25 ++++++++++++++++++-------
test/lisp/ido-tests.el | 7 +++++++
3 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 5e5d942d89..3e3454bd93 100644
--- 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'.
diff --git a/lisp/ido.el b/lisp/ido.el
index 0854014581..81b3cd64fc 100644
--- a/lisp/ido.el
+++ b/lisp/ido.el
@@ -735,6 +735,14 @@ ido-max-directory-size
(integer :tag "Size in bytes" 30000))
:group 'ido)
+(defcustom ido-big-directories nil
+ "List of directory pattern strings that should be considered big.
+Ido will ignore directories matching any of these regular
+expressions."
+ :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 @@ ido-directory-too-big-p
;; 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
diff --git a/test/lisp/ido-tests.el b/test/lisp/ido-tests.el
index cb8f1d6306..c9736eb3ec 100644
--- a/test/lisp/ido-tests.el
+++ b/test/lisp/ido-tests.el
@@ -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
--
2.20.1 (Apple Git-117)
next prev parent reply other threads:[~2019-04-17 18:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-12 12:23 [PATCH] Add a new user option 'ido-big-directories' Philipp Stephani
2019-04-12 12:58 ` Eli Zaretskii
2019-04-17 18:30 ` Philipp Stephani
2019-04-17 18:31 ` Philipp Stephani [this message]
2019-04-18 14:40 ` Eli Zaretskii
2019-04-19 8:35 ` Philipp Stephani
2019-04-17 18:58 ` Óscar Fuentes
2019-04-19 9:10 ` Philipp Stephani
2019-04-19 12:23 ` Óscar Fuentes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190417183152.42323-1-phst@google.com \
--to=p.stephani2@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.