GNU bug report logs - #41423
27.0.91; eshell file completion in tramp dir is slow (3 minutes) [regression on pretest]

Previous Next

Package: emacs;

Reported by: rrandresf <at> gmail.com

Date: Wed, 20 May 2020 16:23:02 UTC

Severity: normal

Tags: moreinfo

Merged with 47389

Found in versions 27.0.91, 27.1.91

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #140 received at 41423 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: andrés ramírez <rrandresf <at> gmail.com>
Cc: Lars Magne Ingebrigtsen <larsi <at> gnus.org>, Eli Zaretskii <eliz <at> gnu.org>,
 41423 <at> debbugs.gnu.org
Subject: Re: Installing the fix for bug#41423 on emacs-27
Date: Mon, 01 Feb 2021 11:13:14 -0500
> If You code the 'minimalist version of the patch'. I could try it on this
> version.

See patch below.  You don't need to rebuild Emacs either: just recompile
that one file and you're done.

> commands ).  That would simplify compiling emacs master on lower end
> machines like my SBC {Single Board Computer}.

I know what you mean (recompiling Emacs on my takes quite a while on
some of my machines (BananaPi, Mele-A1000, and Thinkpad X30), especially
because my build scripts enable all debug options, which makes it even
slower).


        Stefan


diff --git a/lisp/eshell/em-cmpl.el b/lisp/eshell/em-cmpl.el
index faf749d836..744be525ec 100644
--- a/lisp/eshell/em-cmpl.el
+++ b/lisp/eshell/em-cmpl.el
@@ -399,16 +399,21 @@
 
 (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, especially over Tramp
+  ;; (bug#41423), so do it lazily.
+  (let ((glob-name
+	 ;; When a command is specified using `eshell-explicit-command-char',
+         ;; that char is not part of the command and hence not part of what
+         ;; we complete.  Adjust `pcomplete-stub' accordingly!
+	 (if (and (> (length pcomplete-stub) 0)
+	          (eq (aref pcomplete-stub 0) eshell-explicit-command-char))
+	     (setq pcomplete-stub (substring pcomplete-stub 1)))))
+    (completion-table-dynamic
+     (lambda (filename)
     (if (file-name-directory filename)
         (if eshell-force-execution
             (pcomplete-dirs-or-entries nil #'file-readable-p)
           (pcomplete-executables))
-      (if (and (> (length filename) 0)
-	       (eq (aref filename 0) eshell-explicit-command-char))
-	  (setq filename (substring filename 1)
-		pcomplete-stub filename
-		glob-name t))
       (let* ((paths (eshell-get-path))
 	     (cwd (file-name-as-directory
 		   (expand-file-name default-directory)))
@@ -455,7 +460,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")
 





This bug report was last modified 3 years and 25 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.