From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: [PATCH] Add a new user option 'ido-big-directories'. Date: Fri, 12 Apr 2019 14:23:01 +0200 Message-ID: <20190412122301.98921-1-phst@google.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="68194"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Philipp Stephani To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Apr 12 14:28:33 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hEvIG-000HZ0-7G for ged-emacs-devel@m.gmane.org; Fri, 12 Apr 2019 14:28:32 +0200 Original-Received: from localhost ([127.0.0.1]:35632 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEvIA-0005Kh-0v for ged-emacs-devel@m.gmane.org; Fri, 12 Apr 2019 08:28:26 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:38211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEvDl-000075-10 for emacs-devel@gnu.org; Fri, 12 Apr 2019 08:23:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEvDk-0000lg-17 for emacs-devel@gnu.org; Fri, 12 Apr 2019 08:23:53 -0400 Original-Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]:41404) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hEvDj-0000lB-Oj for emacs-devel@gnu.org; Fri, 12 Apr 2019 08:23:51 -0400 Original-Received: by mail-wr1-x42e.google.com with SMTP id r4so11651931wrq.8 for ; Fri, 12 Apr 2019 05:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HINPoxHZY8FYNgkptn2MUuq3CZXeWc0qzMaPQv8q8R8=; b=o9Baj3azR3TSyRkwY3VtDSkaWw8ZidND+2X3T0AII941WT1jxN4mcBYI+jGIabjQ8+ ue28wnkYjuUTsa0dG0q3jJP1qp+6VcNTE+smBSL/pfJKqHS/NCHDu/as+b1UJgXEddkB RPYM8NAbSl66b+LSZ+SqIn4YJqL5QMZT37fBoeZSIuHO4F0tpx8S6/OoC2gsAedUwc+R U0ch9rGYLBpc8U1sXneMqQGzV12Yk32nzpX4hORSt+5TEHgJaCz0003BaaOBXdD/VVss P+B9IH513CLtjXJSnlsU7+MqQevknIxh/CPjmGqNr3mO6sNOxAjXISn5noomRDHnv3z9 wjyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=HINPoxHZY8FYNgkptn2MUuq3CZXeWc0qzMaPQv8q8R8=; b=blhUp8nqOudb1Tx4fqDB1Qf0OuK8BX0IMG7RvH1J/nKf1DmpGGwLq0TYlPGW55p6L6 43prUrw4S7klgofgBoReKq64PPnlLn4/am9qlobfmjmN360vsJNr5pKBR/1gddrfVDWv ihEzMjhLlOwhXw1z84oJKvMv6/AcuyBgnXz36Hpsmq1SS0m5uF9zvih+9og/G82FzDUs JqqA8I463JS2q76wSECRiATZ+UxUDiPc0+ZaX23sOfxK0B87Sr1BfKmxUGe4JfSE767Y I7gmeil8Blv3Ly8hVy8RnXoWHXmUq0JSM6Sad+mvI6E99yPLdyNhIljhfZYdAKINnJcT ZQrg== X-Gm-Message-State: APjAAAXG3Lds3nXZiJzMGYWPMX/WiEyN8G3JVye/BDZi+bdCTX2F7U/d hH/pn4+BElfH6ji901sRLD7LEL1t X-Google-Smtp-Source: APXvYqws72SvlSlgC3KKrVII1oY/iuLbaHZJyKbvMhlFWVrZvDqAz8GiQcIlmyxJGUangf5e6DM+Jg== X-Received: by 2002:adf:f30a:: with SMTP id i10mr34941468wro.111.1555071829278; Fri, 12 Apr 2019 05:23:49 -0700 (PDT) Original-Received: from phst1.corp.google.com ([2a00:79e0:15:14:5747:5138:b7f6:6559]) by smtp.gmail.com with ESMTPSA id v184sm15508741wma.6.2019.04.12.05.23.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Apr 2019 05:23:48 -0700 (PDT) X-Google-Original-From: Philipp Stephani X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:235336 Archived-At: 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