unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Gregory Heytings <ghe@sdf.org>
Cc: rrandresf@gmail.com, Tim Vaughan <timv@ughan.xyz>,
	41423@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#41423: 27.0.91; eshell file completion in tramp dir is slow (3 minutes) [regression on pretest]
Date: Sat, 29 Aug 2020 14:38:45 +0200	[thread overview]
Message-ID: <87mu2d7hka.fsf@gmx.de> (raw)
In-Reply-To: <alpine.NEB.2.22.394.2008290031430453.17495@sdf.lonestar.org> (Gregory Heytings's message of "Fri, 28 Aug 2020 23:15:12 +0000")

[-- Attachment #1: Type: text/plain, Size: 2798 bytes --]

Gregory Heytings <ghe@sdf.org> writes:

Hi,

> Apparently my previous last note was not the last one ;-)
>
> I still don't know how this bug should be fixed (except by using (setq
> completion-at-point-functions '(pcomplete t))), but here is a more
> detailed explanation of what is happening, at least how I understand
> it:
>
> 1. TAB calls completion-at-point
> 2. completion-at-point calls pcomplete-completions-at-point, which
> calls pcomplete/cd; this completes the directory name
> 3. completion-at-point let-binds completion-in-region-mode-predicate
> to a lambda, which contains pcomplete-completion-at-point
> 4. completion-at-point calls completion-in-region, which adds
> completion-in-region--postch to post-command-hook
> 5. post-command-hook calls completion-in-region--postch
> 6. completion-in-region--postch funcalls completion-in-region-mode-predicate
> 7. this calls pcomplete-completions-at-point a second time, which
> again calls pcomplete/cd (and adds a '/' after the directory name (?))
> 8. RET is pressed
> 9. post-command-hook still contains completion-in-region--postch: it
> is called again
> 10. completion-in-region--postch funcalls
> completion-in-region-mode-predicate again
> 11. this calls pcomplete-completions-at-point a third (!) time
> 12. at this point pcomplete-completions-at-point considers (for some
> reason, possibly because the last character of the input is '/' (?))
> that it is a command that it must now complete
> 13. therefore instead of calling pcomplete/cd a third time,
> pcomplete-completions-at-point now calls eshell-complete-commands-list
> 14. this loops through all possible command names (on the local or remote host)
> 15. if all command names had had a common prefix, that prefix would
> have been inserted now, but this is not the case, so the effect of
> this loop (apart from a waste of time) is nil
>
> The fact that default-directory is remote is not important here, the
> exact same steps take place when it is local, except that step 15 is
> executed much faster.
>
> At step 15 it is possible to interrupt the loop with C-g.  At step 8
> it is possible to remove completion-in-region--postch from
> post-command-hook for example by switching buffers with C-x C-b.
>
> Why such a overly complicated mechanism is used, or what should be
> done to avoid this behavior, is beyond my understanding.

I don't know the completion machinery, so I'm adding Stefan who might
know better.

However, the remote case could be improved. Tramp uses caches. They
expire after a while (10 seconds per default), but this might be
improved. The appended patch disables Tramp cache expiry while being in
eshell-complete-commands-list, so completion might be faster once the
cache has been filled. Could you pls check?

Best regards, Michael.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 816 bytes --]

*** /tmp/ediff046iSD	2020-08-29 14:36:21.788278641 +0200
--- /usr/local/src/emacs-27/lisp/eshell/em-cmpl.el	2020-08-29 14:22:38.781483169 +0200
***************
*** 399,405 ****

  (defun eshell-complete-commands-list ()
    "Generate list of applicable, visible commands."
!   (let ((filename (pcomplete-arg)) glob-name)
      (if (file-name-directory filename)
          (if eshell-force-execution
              (pcomplete-dirs-or-entries nil #'file-readable-p)
--- 399,405 ----

  (defun eshell-complete-commands-list ()
    "Generate list of applicable, visible commands."
!   (let ((filename (pcomplete-arg)) glob-name remote-file-name-inhibit-cache)
      (if (file-name-directory filename)
          (if eshell-force-execution
              (pcomplete-dirs-or-entries nil #'file-readable-p)

  reply	other threads:[~2020-08-29 12:38 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20 16:20 bug#41423: 27.0.91; tramp regression on pretest rrandresf
     [not found] ` <handler.41423.B.158999173030371.ack@debbugs.gnu.org>
2020-05-20 17:35   ` bug#41423: additional info andrés ramírez
2020-05-28 11:48     ` bug#41423: 27.0.91; eshell file completion in tramp dir is slow (3 minutes) [regression on pretest] (was: bug#41423: additional info) Michael Albinus
2021-02-01  2:45       ` bug#41423: 27.0.91; eshell file completion in tramp dir is slow (3 minutes) [regression on pretest] Stefan Monnier
2021-02-01  4:36         ` bug#41423: Installing the fix for bug#41423 on emacs-27 (was: 27.0.91; eshell file completion in tramp dir is slow (3 minutes) [regression on pretest]) Stefan Monnier
2021-02-01  9:59           ` bug#41423: Installing the fix for bug#41423 on emacs-27 Michael Albinus
2021-02-01 14:47           ` bug#41423: Installing the fix for bug#41423 on emacs-27 (was: 27.0.91; eshell file completion in tramp dir is slow (3 minutes) [regression on pretest]) Eli Zaretskii
2021-02-01 15:33             ` bug#41423: Installing the fix for bug#41423 on emacs-27 Stefan Monnier
2021-02-01 15:53               ` andrés ramírez
2021-02-01 16:13                 ` Stefan Monnier
2021-02-01 17:35                   ` andrés ramírez
2022-06-27  8:29                   ` bug#41423: bug#47389: 27.1.91; completion issue on eshell Lars Ingebrigtsen
2022-06-27 11:37                     ` andrés ramírez
2022-06-27 11:44                       ` Lars Ingebrigtsen
2020-08-19 10:24 ` bug#41423: 27.0.91; eshell file completion in tramp dir is slow (3 minutes) [regression on pretest] Tim Vaughan via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-27 14:38 ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-28  9:32   ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-28 13:17     ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-28 23:15       ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-29 12:38         ` Michael Albinus [this message]
2020-08-29 15:44           ` Stefan Monnier
2020-08-29 16:12             ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-30  3:55               ` Stefan Monnier
2020-08-30 22:28                 ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-31  8:30                   ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-01  4:23                   ` Stefan Monnier
2020-09-01  8:31                     ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-01 10:14                       ` Eli Zaretskii
2020-09-01 11:50                         ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-01 13:08                           ` Stefan Monnier
2020-09-01 13:30                             ` Stefan Monnier
2020-09-01 15:41                               ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-01 13:04                       ` Stefan Monnier
2020-09-01 15:40                         ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-02  0:31                           ` Stefan Monnier
2020-09-02 10:26                             ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-02 10:33                               ` Michael Albinus
2020-09-02 16:00                                 ` Drew Adams
2021-01-31 17:07                                   ` xristos--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-02 16:36                               ` Stefan Monnier
2020-09-02 19:52                                 ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-02 20:08                                   ` Stefan Monnier
2020-08-29 13:08 ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-29 16:54   ` Michael Albinus
2020-08-29 17:14     ` Gregory Heytings via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-08-29 17:28       ` Michael Albinus
2021-04-21 16:06 ` bug#41423: Installing the fix for bug#41423 on emacs-27 Andrés Ramírez
2021-04-23 22:14   ` Stefan Monnier
2021-04-24  3:37     ` andrés ramírez

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87mu2d7hka.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=41423@debbugs.gnu.org \
    --cc=ghe@sdf.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=rrandresf@gmail.com \
    --cc=timv@ughan.xyz \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).