unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Thierry Volpiatto <thierry.volpiatto@gmail.com>
Cc: 16197@debbugs.gnu.org
Subject: bug#16197: 24.3.50; no completion on commands following "sudo" in shell and eshell
Date: Fri, 25 Sep 2020 13:51:05 -0400	[thread overview]
Message-ID: <jwvlfgxhhx9.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <8738l2hode.fsf@gmail.com> (Thierry Volpiatto's message of "Sun,  05 Jan 2014 08:35:57 +0100")

> emacs -Q
> M-x shell
> $ find . -name '*.el' | xargs et!
> Press TAB, nothing, no completion against "et".

The patch below seems to address this problem for me.
Now I can do

    M-x shell
    % xargs cv TAB

and I get a list is commands starting with "cv"; and

    % xargs cvs TAB

lists `cvs`s subcommands.

> M-: (shell-backward-command)
> I have now the cursor at xargs:

That seems right to me.  I think changing it the way you describe could
lead to more problems down the line for cases where
`shell-backward-command` is used for other purposes.

> $ find . -name '*.el' | !xargs et
> To provide completion against "et" I should have the cursor at:
> $ find . -name '*.el' | xargs !et
> after evaling (shell-backward-command).

The beginning of the command is definitely "xargs" and not "et".
The fact that the first arg to the command is itself a command shouldn't
change where is the beginning of the command here, I think.

> For `pcomplete-command-name' it is harder to give a recipe, the best is
> to edebug it to have an idea (be careful the actual version is crashing
> emacs sometimes).

Same here, I'd think that the "command name" is "xargs", but rather than
argue about this philosophical point, it's probably better to focus on
more concrete cases where this return value is a problem.


        Stefan


diff --git a/lisp/pcmpl-unix.el b/lisp/pcmpl-unix.el
index dc0d729849..27584c27a7 100644
--- a/lisp/pcmpl-unix.el
+++ b/lisp/pcmpl-unix.el
@@ -83,7 +83,7 @@ pcomplete/rm
 ;;;###autoload
 (defun pcomplete/xargs ()
   "Completion for `xargs'."
-  (pcomplete-here (funcall pcomplete-command-completion-function))
+  (funcall pcomplete-command-completion-function)
   (funcall (or (pcomplete-find-completion-function (pcomplete-arg 1))
 	       pcomplete-default-completion-function)))
 
diff --git a/lisp/shell.el b/lisp/shell.el
index e574aac99d..d2c41a9690 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -461,9 +461,12 @@ shell-command-completion-function
 This is the value of `pcomplete-command-completion-function' for
 Shell buffers.  It implements `shell-completion-execonly' for
 `pcomplete' completion."
-  (pcomplete-here (pcomplete-entries nil
-				     (if shell-completion-execonly
-					 'file-executable-p))))
+  (if (pcomplete-match "/")
+      (pcomplete-here (pcomplete-entries nil
+					 (if shell-completion-execonly
+					     'file-executable-p)))
+    (pcomplete-here
+     (nth 2 (shell--command-completion-data)))))
 
 (defun shell-completion-vars ()
   "Setup completion vars for `shell-mode' and `read-shell-command'."






  reply	other threads:[~2020-09-25 17:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20  8:18 bug#16197: 24.3.50; no completion on commands following "sudo" in shell and eshell Thierry Volpiatto
2013-12-23  8:36 ` Thierry Volpiatto
2013-12-23 10:21   ` Thierry Volpiatto
2013-12-24  6:59     ` Thierry Volpiatto
2013-12-24 10:49       ` Thierry Volpiatto
2014-01-03 22:53         ` Stefan Monnier
2014-01-04  5:33           ` Thierry Volpiatto
2014-01-04  7:11             ` Thierry Volpiatto
2014-01-04 20:26             ` Stefan Monnier
2014-01-05  7:35               ` Thierry Volpiatto
2020-09-25 17:51                 ` Stefan Monnier [this message]
2020-09-26 13:09                   ` Lars Ingebrigtsen
2020-09-26 22:17                     ` Stefan Monnier
2020-09-27 12:08                       ` Lars Ingebrigtsen
2020-09-28  2:07                         ` Stefan Monnier
2020-09-28 11:12                           ` Lars Ingebrigtsen
2014-01-07 13:11               ` Thierry Volpiatto
2020-09-25 10:44                 ` Lars Ingebrigtsen
2014-01-07 15:26               ` Thierry Volpiatto

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=jwvlfgxhhx9.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=16197@debbugs.gnu.org \
    --cc=thierry.volpiatto@gmail.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 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).