Subject: Re: bug#23006: 25.0.92; Loading Tramp breaks pcomplete in eshell-mode

From: Michael Albinus <[email-masked]>
Date: Tue, 22 Mar 2016 13:20:27 +0100

Stefan Monnier <[email-masked]> writes:

>> Tramp needs an indication that file name completion is in progress.
>
> That's where we disagree.
>
>> Otherwise, it would regard remote file names like "/adb:" safe
>> to be handled, and it would report an error then.
>
> This bug report is not about "cd /adb: TAB signals an error" but about
> "cd / TAB signals an error".  The "/adb:" part comes from Tramp because
> of a problem in Tramp's implementation of file-name-directory, AFAICT.
> It has nothing to do with file name completion.

cd / TAB calls file-name-all-completions. This returns several
candidates, like "/adb:". That's OK.

Afterwards, (file-directory-p "adb:") is called from completion-file-name-table:

  ...
  expand-file-name("adb:" "/")
  apply(expand-file-name ("adb:" "/"))
  (let* ((inhibit-file-name-handlers (cons (quote tramp-completion-file-name-handler) (cons (quote cygwin-mount-name-hook-function) (cons (quote cygwin-mount-map-drive-hook-function) (and (eq inhibit-file-name-operation operation) inhibit-file-name-handlers))))) (inhibit-file-name-operation operation)) (apply operation args))
  tramp-completion-run-real-handler(expand-file-name ("adb:" "/"))
  (if (and fn tramp-mode (or (eq tramp-syntax (quote sep)) (featurep (quote tramp)) (and (boundp (quote partial-completion-mode)) (symbol-value (quote partial-completion-mode))) (featurep (quote ido)) (featurep (quote icicles)))) (let ((save-match-data-internal (match-data))) (unwind-protect (progn (apply (cdr fn) args)) (set-match-data save-match-data-internal (quote evaporate)))) (tramp-completion-run-real-handler operation args))
  tramp-completion-file-name-handler(expand-file-name "adb:" "/")
  file-directory-p("adb:")
  #[257 "\302\203\n\302!\205\301\203\301!\205\300?\206\300!\207" [file-directory-p #[257 "\211GSH\302=\203\301\205\303\301\"\202\300\205\303\300\"?\207" ["~\\'" "\\`\\(\\.\\.?\\|CVS\\)/\\'" 47 string-match] 4 "\n\n(fn FILE)"] nil] 3 "\n\n(fn F)"]("adb:")
  completion-file-name-table("/" #[257 "\302\203\n\302!\205\301\203\301!\205\300?\206\300!\207" [file-directory-p #[257 "\211GSH\302=\203\301\205\303\301\"\202\300\205\303\300\"?\207" ["~\\'" "\\`\\(\\.\\.?\\|CVS\\)/\\'" 47 string-match] 4 "\n\n(fn FILE)"] nil] 3 "\n\n(fn F)"] t)
  comint-completion-file-name-table("/" #[257 "\302\203\n\302!\205\301\203\301!\205\300?\206\300!\207" [file-directory-p #[257 "\211GSH\302=\203\301\205\303\301\"\202\300\205\303\300\"?\207" ["~\\'" "\\`\\(\\.\\.?\\|CVS\\)/\\'" 47 string-match] 4 "\n\n(fn FILE)"] nil] 3 "\n\n(fn F)"] t)
  complete-with-action(t comint-completion-file-name-table "/" #[257 "\302\203\n\302!\205\301\203\301!\205\300?\206\300!\207" [file-directory-p #[257 "\211GSH\302=\203\301\205\303\301\"\202\300\205\303\300\"?\207" ["~\\'" "\\`\\(\\.\\.?\\|CVS\\)/\\'" 47 string-match] 4 "\n\n(fn FILE)"] nil] 3 "\n\n(fn F)"])
  completion-table-with-predicate(comint-completion-file-name-table #[257 "\302\203\n\302!\205\301\203\301!\205\300?\206\300!\207" [file-directory-p #[257 "\211GSH\302=\203\301\205\303\301\"\202\300\205\303\300\"?\207" ["~\\'" "\\`\\(\\.\\.?\\|CVS\\)/\\'" 47 string-match] 4 "\n\n(fn FILE)"] nil] 3 "\n\n(fn F)"] strict "/" nil t)
  pcomplete(1)
  funcall-interactively(pcomplete 1)
  call-interactively(pcomplete record nil)
  command-execute(pcomplete record)
  execute-extended-command(nil "pcomplete" "pcomplete")
  funcall-interactively(execute-extended-command nil "pcomplete" "pcomplete")
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)

Tramp has no information, that file-name-completion is still in
progress, and does its job. It tries to connect to the remote host
"/adb:" in order to check.

If Tramp would have been said, that file name completion is still in
progress, it would behave correctly.

And it isn't only about file-directory-p, that's just an example. *Any*
file name operation could be called while file name completion is in
progress. That's why Tramp needs this information.

And yes, this is our basic disagreement. I'm not able to implement
proper Tramp operation without this information. Why do you refuse to
tell this to Tramp?

>         Stefan

Best regards, Michael.