GNU bug report logs - #65356
30.0.50; [wishlist] Support Tramp method, user name and host name completion in eshell

Previous Next

Package: emacs;

Reported by: Michael Albinus <michael.albinus <at> gmx.de>

Date: Thu, 17 Aug 2023 18:03:01 UTC

Severity: wishlist

Merged with 74177

Found in versions 29.4, 30.0.50

Fixed in version 30.1

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

Full log


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

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Jim Porter <jporterbugs <at> gmail.com>
Cc: 65356 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#65356: 30.0.50; [wishlist] Support Tramp method, user name
 and host name completion in eshell
Date: Fri, 18 Aug 2023 13:43:42 +0200
Michael Albinus <michael.albinus <at> gmx.de> writes:

Hi Jim,

>> 2) I'm not sure 'pcomplete-try-first-hook' is the right way to enable
>> this. Pcomplete has quite a few ways of performing completions, and it
>> already knows when it should specifically complete file names (as
>> opposed to "--options" for example). Maybe we should enhance Pcomplete
>> itself so that you can opt into completion of remote file names too?
>> Then when you tab-complete in Eshell, it would just work in all the
>> contexts where you can normally complete a file name. I Cc'ed Stefan
>> since he might have some thoughts on the Pcomplete machinery here.
>
> When I've started to implement this, I was a n00b wrt pcomplete. Well,
> I'm still a n00b, all what I have done is stealing code from somewhere
> else, shamelessly.
>
> It would be great if this completion function applies only to possible
> *Lisp* file names. Roughly said, to arguments of commands not being
> external, and not in a pipe. If this could be arranged I'd appreciate
> it. So I count on you and Stefan :-)

I've digged further. Perhaps, we don't need to plug into eshell. It
could be sufficient to teach pcomplete.

First, we need a completion table for Tramp prefixes. Like

--8<---------------cut here---------------start------------->8---
(defun pcomplete-tramp ()
  "Completion table for partial Tramp file names."
  (completion-table-dynamic
   (lambda (string)
     (when (string-match-p tramp-completion-file-name-regexp string)
       (mapcar
	(lambda (x) (concat tramp-prefix-format x))
	(let ((non-essential t)
	      (minibuffer-completing-file-name t))
	  (file-name-all-completions string tramp-prefix-format)))))))
--8<---------------cut here---------------end--------------->8---

We could use this table to pimp up (existing) pcomplete functions for
builtin commands, like

--8<---------------cut here---------------start------------->8---
(defun pcomplete/cd ()
  "Completion for `cd'."
  (while (pcomplete-here (completion-table-in-turn
			  (pcomplete-tramp)
			  (pcomplete-dirs)))))
--8<---------------cut here---------------end--------------->8---

WDYT?

Best regards, Michael.




This bug report was last modified 256 days ago.

Previous Next


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