bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#41423: 27.0.91; eshell file completion in tramp dir is slow (3 minut


From: Stefan Monnier
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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> 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")
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]