From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#41423: 27.0.91; eshell file completion in tramp dir is slow (3 minutes) [regression on pretest] Date: Tue, 01 Sep 2020 09:30:07 -0400 Message-ID: References: <87mu2d7hka.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39419"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Tim Vaughan , rrandresf@gmail.com, Michael Albinus , 41423@debbugs.gnu.org To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 01 15:31:12 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kD6NU-000A9a-KD for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Sep 2020 15:31:12 +0200 Original-Received: from localhost ([::1]:52278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kD6NT-0008DA-E9 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 01 Sep 2020 09:31:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44392) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kD6NK-0008Aj-RR for bug-gnu-emacs@gnu.org; Tue, 01 Sep 2020 09:31:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43827) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kD6NK-00075F-GS for bug-gnu-emacs@gnu.org; Tue, 01 Sep 2020 09:31:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kD6NK-0007aD-D8 for bug-gnu-emacs@gnu.org; Tue, 01 Sep 2020 09:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 01 Sep 2020 13:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41423 X-GNU-PR-Package: emacs Original-Received: via spool by 41423-submit@debbugs.gnu.org id=B41423.159896701929101 (code B ref 41423); Tue, 01 Sep 2020 13:31:02 +0000 Original-Received: (at 41423) by debbugs.gnu.org; 1 Sep 2020 13:30:19 +0000 Original-Received: from localhost ([127.0.0.1]:55373 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kD6Md-0007ZJ-5R for submit@debbugs.gnu.org; Tue, 01 Sep 2020 09:30:19 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:50947) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kD6Ma-0007Z3-No for 41423@debbugs.gnu.org; Tue, 01 Sep 2020 09:30:17 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 53A9A80922; Tue, 1 Sep 2020 09:30:11 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 88A888066B; Tue, 1 Sep 2020 09:30:09 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1598967009; bh=K8GjzoEmo5w227a05xSqZiYIGE5acpsxJ8jBkrtzU+4=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=fRx4gUhPkFSsB0ul0Fsiw37jZxUG+l/TlIVZZyK2dgAigKU66T9dwvxnq3kpqAlRg C5RGYPXl8Q/kWrGl3dq7Qjw2A75QS/UDihzZ2RVKi6QjLG8lBlmOHWv8L0alBpGSsP m2K4ZIr48/MrcpCQWACcETP7xaOTmHzrDSCpXe7JspQcJ/vYabWmEhBe4er+qzGJsL jz5+9Rw1OfMe56F8RmMsdkUxCSXNWqYrNXOLFd+ni1qLpzHovudwsFgk4ZWzRV3t8T JnhEoq0dLIAsWT69D4RyKAULhY2s+YtOVOu8QuIm+WilW5gqDve/qBRiRvVQU4X48G NumVhrioYo0Tg== Original-Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4235C1202F4; Tue, 1 Sep 2020 09:30:09 -0400 (EDT) In-Reply-To: (Stefan Monnier's message of "Tue, 01 Sep 2020 09:08:28 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:186832 Archived-At: > And the fix is to make this third call return in 0.00 seconds like the > others by making it return not the list of commands but a mere function > (which will return that list of commands only when called, but in the > present case it won't be called). See for example patch below (which shouldn't be applied as-is since the body of the function ends up misindented). Stefan diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el index 48c99acac3..e41afea9ef 100644 --- a/lisp/eshell/em-cmpl.el +++ b/lisp/eshell/em-cmpl.el @@ -399,11 +399,15 @@ (defun eshell-complete-commands-list () "Generate list of applicable, visible commands." - (let ((filename (pcomplete-arg)) glob-name) + ;; Building the commands list can take quite a while over Tramp + ;; (bug#41423), so do it lazily. + (completion-table-dynamic + (lambda (filename) (if (file-name-directory filename) (if eshell-force-execution (pcomplete-dirs-or-entries nil #'file-readable-p) (pcomplete-executables)) + (let (glob-name) (if (and (> (length filename) 0) (eq (aref filename 0) eshell-explicit-command-char)) (setq filename (substring filename 1) @@ -455,7 +459,7 @@ (and eshell-show-lisp-alternatives (null completions))) (all-completions filename obarray #'functionp)) - completions))))))) + completions))))))))) (define-obsolete-function-alias 'eshell-pcomplete #'completion-at-point "27.1")