all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Wayne Harris via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: why is my cd command on eshell on Windows so slow?
Date: Fri, 16 Apr 2021 21:10:10 -0300	[thread overview]
Message-ID: <86sg3p6aal.fsf@protonmail.com> (raw)
In-Reply-To: jwvk0p2djb1.fsf-monnier+emacs@gnu.org

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>>> %cd dir/
>>>> 0.001 secs
>>>> %
> [...]
>> It appears that the delay has nothing to do with Windows or with the
>> cd-command.  It seems to be the procedure
>>
>>   completion-in-region--postch
>
> Sounds like bug#41423.
> If that's the case, then I suggest you try the code in Emacs's `master`
> where it should be fixed.

It really sounds like bug#41423, even because the workaround provided by
Gregory Heytings solves the problem, that is, I don't notice any slow
down after applying:

--8<---------------cut here---------------start------------->8---
(add-hook
 'eshell-mode-hook
 (function (lambda ()
             (setq completion-at-point-functions '(pcomplete t)))))
--8<---------------cut here---------------end--------------->8---

On the other hand, applying your patch...

--8<---------------cut here---------------start------------->8---
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")
--8<---------------cut here---------------end--------------->8---

...does not make any noticeable change.  Should I try a clean master to
make sure I'm doing the right thing here?  Notice my case the slow down
is only involved with local files, no tramp business.  I do experience
the ~0.5-second delay mentioned by Tim Vaughan.  (Sometimes it takes
longer.)

Thanks!




  reply	other threads:[~2021-04-17  0:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 18:40 why is my cd command on eshell on Windows so slow? Wayne Harris via Users list for the GNU Emacs text editor
2021-04-16 18:59 ` Eli Zaretskii
2021-04-16 20:14   ` Wayne Harris via Users list for the GNU Emacs text editor
2021-04-16 21:14     ` Stefan Monnier
2021-04-17  0:10       ` Wayne Harris via Users list for the GNU Emacs text editor [this message]
2021-04-17  8:28         ` Wayne Harris via Users list for the GNU Emacs text editor
2021-04-17 14:08           ` Stefan Monnier
2021-04-17 14:32             ` Óscar Fuentes
2021-04-17 14:39               ` Eli Zaretskii
2021-04-17 14:56                 ` Óscar Fuentes
2021-04-17 15:05                   ` Eli Zaretskii
2021-04-17 14:41               ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86sg3p6aal.fsf@protonmail.com \
    --to=help-gnu-emacs@gnu.org \
    --cc=wharris1@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.