* [PATCH] Add a new user option 'ido-big-directories'.
@ 2019-04-12 12:23 Philipp Stephani
2019-04-12 12:58 ` Eli Zaretskii
2019-04-17 18:58 ` Óscar Fuentes
0 siblings, 2 replies; 9+ messages in thread
From: Philipp Stephani @ 2019-04-12 12:23 UTC (permalink / raw)
To: emacs-devel; +Cc: Philipp Stephani
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 | 4 ++++
lisp/ido.el | 25 ++++++++++++++++++-------
test/lisp/ido-tests.el | 7 +++++++
3 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 9644c1ca22..8affadde6b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -402,6 +402,10 @@ 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 certain directory
+patterns as big.
+
** 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..b5969f734c 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
+ "Additional directories 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.21.0.392.gf8f6787159e-goog
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Add a new user option 'ido-big-directories'.
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:58 ` Óscar Fuentes
1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2019-04-12 12:58 UTC (permalink / raw)
To: Philipp Stephani; +Cc: phst, emacs-devel
> From: Philipp Stephani <p.stephani2@gmail.com>
> Date: Fri, 12 Apr 2019 14:23:01 +0200
> Cc: Philipp Stephani <phst@google.com>
>
> This provides an alternative to 'ido-max-directory-size', for
> directories that are statically known to be too big for Ido
> completion.
Thanks.
> +** Ido
> +*** New user option 'ido-big-directories' to mark certain directory
> +patterns as big.
This doesn't say what is a "pattern" and what is the meaning of "big"
in this context. Could that be at least hinted at?
> +(defcustom ido-big-directories nil
> + "Additional directories that should be considered big.
> +Ido will ignore directories matching any of these regular
> +expressions."
The doc string should explicitly say what is the form of the value.
Also, since the elements of the sequence are regular expressions, the
first sentence should mention that, or at least say they are strings.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add a new user option 'ido-big-directories'.
2019-04-12 12:58 ` Eli Zaretskii
@ 2019-04-17 18:30 ` Philipp Stephani
2019-04-17 18:31 ` Philipp Stephani
0 siblings, 1 reply; 9+ messages in thread
From: Philipp Stephani @ 2019-04-17 18:30 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Philipp Stephani, Emacs developers
Am Fr., 12. Apr. 2019 um 14:59 Uhr schrieb Eli Zaretskii <eliz@gnu.org>:
>
> > From: Philipp Stephani <p.stephani2@gmail.com>
> > Date: Fri, 12 Apr 2019 14:23:01 +0200
> > Cc: Philipp Stephani <phst@google.com>
> >
> > This provides an alternative to 'ido-max-directory-size', for
> > directories that are statically known to be too big for Ido
> > completion.
>
> Thanks.
>
> > +** Ido
> > +*** New user option 'ido-big-directories' to mark certain directory
> > +patterns as big.
>
> This doesn't say what is a "pattern" and what is the meaning of "big"
> in this context. Could that be at least hinted at?
>
> > +(defcustom ido-big-directories nil
> > + "Additional directories that should be considered big.
> > +Ido will ignore directories matching any of these regular
> > +expressions."
>
> The doc string should explicitly say what is the form of the value.
> Also, since the elements of the sequence are regular expressions, the
> first sentence should mention that, or at least say they are strings.
Thanks, I'll send a new patch.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] Add a new user option 'ido-big-directories'.
2019-04-17 18:30 ` Philipp Stephani
@ 2019-04-17 18:31 ` Philipp Stephani
2019-04-18 14:40 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Philipp Stephani @ 2019-04-17 18:31 UTC (permalink / raw)
To: eliz, emacs-devel; +Cc: Philipp Stephani
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)
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] Add a new user option 'ido-big-directories'.
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:58 ` Óscar Fuentes
2019-04-19 9:10 ` Philipp Stephani
1 sibling, 1 reply; 9+ messages in thread
From: Óscar Fuentes @ 2019-04-17 18:58 UTC (permalink / raw)
To: Philipp Stephani; +Cc: Philipp Stephani, emacs-devel
Philipp Stephani <p.stephani2@gmail.com> writes:
> 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.
What this option does is to revert to non-ido completion when the
regexp matches the directory name, it has nothing to do with the
directory being big.
I suggest that you rename the user option accordingly and move its use
outside of ido-directory-too-big-p.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add a new user option 'ido-big-directories'.
2019-04-17 18:31 ` Philipp Stephani
@ 2019-04-18 14:40 ` Eli Zaretskii
2019-04-19 8:35 ` Philipp Stephani
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2019-04-18 14:40 UTC (permalink / raw)
To: Philipp Stephani; +Cc: p.stephani2, emacs-devel
> From: Philipp Stephani <p.stephani2@gmail.com>
> Cc: Philipp Stephani <p.stephani2@gmail.com>
> Date: Wed, 17 Apr 2019 20:31:52 +0200
>
> +(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."
I think NEWS describes better what is "big" in this context, so I
suggest to use that instead of the last sentence of the doc string,
which is less precise.
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add a new user option 'ido-big-directories'.
2019-04-18 14:40 ` Eli Zaretskii
@ 2019-04-19 8:35 ` Philipp Stephani
0 siblings, 0 replies; 9+ messages in thread
From: Philipp Stephani @ 2019-04-19 8:35 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Emacs developers
Am Do., 18. Apr. 2019 um 16:40 Uhr schrieb Eli Zaretskii <eliz@gnu.org>:
>
> > From: Philipp Stephani <p.stephani2@gmail.com>
> > Cc: Philipp Stephani <p.stephani2@gmail.com>
> > Date: Wed, 17 Apr 2019 20:31:52 +0200
> >
> > +(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."
>
> I think NEWS describes better what is "big" in this context, so I
> suggest to use that instead of the last sentence of the doc string,
> which is less precise.
>
> Thanks.
Thanks, pushed as f5e3c2cc98.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add a new user option 'ido-big-directories'.
2019-04-17 18:58 ` Óscar Fuentes
@ 2019-04-19 9:10 ` Philipp Stephani
2019-04-19 12:23 ` Óscar Fuentes
0 siblings, 1 reply; 9+ messages in thread
From: Philipp Stephani @ 2019-04-19 9:10 UTC (permalink / raw)
To: Óscar Fuentes; +Cc: Philipp Stephani, Emacs developers
Am Mi., 17. Apr. 2019 um 20:58 Uhr schrieb Óscar Fuentes <ofv@wanadoo.es>:
>
> Philipp Stephani <p.stephani2@gmail.com> writes:
>
> > 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.
>
> What this option does is to revert to non-ido completion when the
> regexp matches the directory name, it has nothing to do with the
> directory being big.
>
> I suggest that you rename the user option accordingly and move its use
> outside of ido-directory-too-big-p.
This is a semantical difference: it's specifically intended to mark
directories as big, and Ido shows "too big" when attempting to
complete such a directory, so I think the name is warranted.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] Add a new user option 'ido-big-directories'.
2019-04-19 9:10 ` Philipp Stephani
@ 2019-04-19 12:23 ` Óscar Fuentes
0 siblings, 0 replies; 9+ messages in thread
From: Óscar Fuentes @ 2019-04-19 12:23 UTC (permalink / raw)
To: emacs-devel
Philipp Stephani <p.stephani2@gmail.com> writes:
> Am Mi., 17. Apr. 2019 um 20:58 Uhr schrieb Óscar Fuentes <ofv@wanadoo.es>:
>>
>> Philipp Stephani <p.stephani2@gmail.com> writes:
>>
>> > 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.
>>
>> What this option does is to revert to non-ido completion when the
>> regexp matches the directory name, it has nothing to do with the
>> directory being big.
>>
>> I suggest that you rename the user option accordingly and move its use
>> outside of ido-directory-too-big-p.
>
> This is a semantical difference: it's specifically intended to mark
> directories as big, and Ido shows "too big" when attempting to
> complete such a directory, so I think the name is warranted.
Since this feature depends on name matching and nothing else, presuming
that its only use is for signaling big directories is projecting your
motivations for implementing it on the rest of the users' needs.
No functionality is lost by turning this from "switch off ido for
directories whose name matches this regexp because they are big" into
"switch off ido for directories whose name matches this regexp". Using
the appropriate name for the defcustom and placing the check on a more
general site you can convey the full applicability of the feature.
My 0.02 cents.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-04-19 12:23 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).