unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Jim Porter <jporterbugs@gmail.com>
Cc: 65356@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#65356: 30.0.50; [wishlist] Support Tramp method, user name and host name completion in eshell
Date: Sat, 19 Aug 2023 19:48:17 +0200	[thread overview]
Message-ID: <87zg2m9b4u.fsf@gmx.de> (raw)
In-Reply-To: <ec2e5867-be57-7baa-16fc-628f7c0aa3dd@gmail.com> (Jim Porter's message of "Fri, 18 Aug 2023 20:26:54 -0700")

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

Jim Porter <jporterbugs@gmail.com> writes:

Hi Jim & Stefan,

>>> Yes. However, there is already another problem in shell-mode. My patch
>>> completes only incomplete Tramp file names, like "/ss". Complete Tramp
>>> file names are handled by pcomplete-dirs already. So we see in a *shell*
>>> buffer, w/o my patch:
>> Good point.
>> Still, we have the problem that `pcomplete/<CMD>` should be used
>> only
>> for external commands (because they are independent from the language
>> used to write the command, a.k.a the shell), but for things like `cd` we
>> should be more precise to distinguish the completion rules for Eshell's
>> `cd` from those of bash's `cd`.
>
> That should be possible by defining 'pcomplete/eshell-mode/CMD', but
> that runs into two issues: 1) it's annoying to manually write all of
> these, and 2) there may be other contexts in Eshell we want to
> tab-complete remote directories that aren't covered by the
> command-specific Pcomplete functions like that.
>
> (#1 should be fixable with a new version of
> 'eshell-eval-using-options', but I haven't looked at that in much
> detail yet.)

I gave it another try. There is a new user option pcomplete-remote-ignore.
When nil (the default), pcomplete expands remote file names, including
method, user name and host name. The corresponding let-bindings in
pcomplete--entries are short.

In shell-completion-vars, I set it buffer-local to t. This prevents
remote file name completion in *shell* buffers, fixing also the bug
mentioned above.

In eshell I haven't set anything, so by default remote file names are
expanded. It should be easy to set pcomplete-remote-ignore, depending
on whether the command is a built-in (keep it nil), or an external
command (set it to t).

The patch is appended. Please note, that this has effect only when Tramp
is loaded, so you might need to test with "emacs -Q -l tramp". People,
who never use Tramp, won't see a difference.

For testing you need a recent checkout of Emacs master, because I have
added another function to tramp.el. This is already pushed to master.

Comments?

Best regards, Michael.


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

diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index c7ec228c1db..e8bede9d605 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -138,6 +138,11 @@ pcomplete-dir-ignore
   "A regexp of names to be disregarded during directory completion."
   :type '(choice regexp (const :tag "None" nil)))

+(defcustom pcomplete-remote-ignore nil
+  "Whether to ignore remote file names."
+  :version "30.1"
+  :type 'boolean)
+
 (define-obsolete-variable-alias 'pcomplete-ignore-case 'completion-ignore-case
   "28.1")

@@ -924,7 +929,10 @@ pcomplete--entries
                            (sort comps pcomplete-compare-entry-function)))
                      ,@(cdr (completion-file-name-table s p a)))
         (let ((completion-ignored-extensions nil)
-	      (completion-ignore-case completion-ignore-case))
+	      (completion-ignore-case completion-ignore-case)
+              (tramp-mode (and tramp-mode (not pcomplete-remote-ignore)))
+              (non-essential (not (file-remote-p s)))
+              (minibuffer-completing-file-name  (not (file-remote-p s))))
           (completion-table-with-predicate
            #'comint-completion-file-name-table pred 'strict s p a))))))

diff --git a/lisp/shell.el b/lisp/shell.el
index 7ea9d1c2ead..17ab12dda6d 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -595,6 +595,8 @@ shell-completion-vars
   ;; Don't use pcomplete's defaulting mechanism, rely on
   ;; shell-dynamic-complete-functions instead.
   (setq-local pcomplete-default-completion-function #'ignore)
+  ;; Do not expand remote file names.
+  (setq-local pcomplete-remote-ignore t)
   (setq-local comint-input-autoexpand shell-input-autoexpand)
   ;; Not needed in shell-mode because it's inherited from comint-mode, but
   ;; placed here for read-shell-command.

  reply	other threads:[~2023-08-19 17:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 18:01 bug#65356: 30.0.50; [wishlist] Support Tramp method, user name and host name completion in eshell Michael Albinus
2023-08-18  3:31 ` Jim Porter
2023-08-18  6:45   ` Michael Albinus
2023-08-18 11:43     ` Michael Albinus
2023-08-18 13:25       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-18 15:12         ` Michael Albinus
2023-08-18 22:33           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-19  3:26             ` Jim Porter
2023-08-19 17:48               ` Michael Albinus [this message]
2023-08-19 18:37                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-19 19:14                   ` Michael Albinus
2023-08-20  0:02                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20  7:50                       ` Michael Albinus
2023-08-20  5:23                 ` Jim Porter
2023-08-20 10:53                   ` Michael Albinus
2023-08-23  0:30                     ` Jim Porter
2023-08-23  7:56                       ` Michael Albinus
2023-08-18 17:50         ` Michael Albinus

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=87zg2m9b4u.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=65356@debbugs.gnu.org \
    --cc=jporterbugs@gmail.com \
    --cc=monnier@iro.umontreal.ca \
    /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).