From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs 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 Message-ID: References: <87fvpolyuk.fsf@gmail.com> <87zjnshslj.fsf@gmail.com> <87vbyfoojc.fsf@gmail.com> <8738lispja.fsf@gmail.com> <8738licym6.fsf@gmail.com> <874n5kfh0x.fsf@gmail.com> <8738l2hode.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17618"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 16197@debbugs.gnu.org To: Thierry Volpiatto Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Sep 25 19:52:11 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kLrtC-0004S2-PR for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Sep 2020 19:52:10 +0200 Original-Received: from localhost ([::1]:37180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLrtB-00055k-Ps for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 25 Sep 2020 13:52:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLrt4-000546-Gw for bug-gnu-emacs@gnu.org; Fri, 25 Sep 2020 13:52:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLrt4-0001sm-6P for bug-gnu-emacs@gnu.org; Fri, 25 Sep 2020 13:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kLrt4-0005JU-5Q for bug-gnu-emacs@gnu.org; Fri, 25 Sep 2020 13:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 25 Sep 2020 17:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16197 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 16197-submit@debbugs.gnu.org id=B16197.160105627620353 (code B ref 16197); Fri, 25 Sep 2020 17:52:02 +0000 Original-Received: (at 16197) by debbugs.gnu.org; 25 Sep 2020 17:51:16 +0000 Original-Received: from localhost ([127.0.0.1]:45267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLrsK-0005ID-Ce for submit@debbugs.gnu.org; Fri, 25 Sep 2020 13:51:16 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34349) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLrsI-0005Ht-P5 for 16197@debbugs.gnu.org; Fri, 25 Sep 2020 13:51:15 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 046614407C0; Fri, 25 Sep 2020 13:51:09 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 55F6D4407A9; Fri, 25 Sep 2020 13:51:07 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1601056267; bh=NA9ri54rG5J10O13bafTdzeklS1CYftE3yEdkntzlWs=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=nYjTGIo5G5Mxm75J8RVqIzk9/BJj63Ivv3RcFkUUFSg9lRPyGNybVtjac74rpRq32 kG+s6tShMclOsJx2m7LOcFDWZazZIy0di1gMZWhFDxLJfR3CyvbZQmTNNBcyFx1Qul EoWJ/2egZnVepjOYzA42QQfqc63BBvSxShqQXVWMu47kNL8KyREBOkV0OR4YOF5lR2 dGf/GQfnbC177HMc+eqRsjFzFaIIITW/4nvKXXRJ7nKzkiks38bxcdZ8LiTRU8rRw6 yBUbjBC43snakYJDg8HNAY9coVikCr+fpsG5LFtEJ7/Vu8VLqu28IJiE0ujFHkyihV vdc0I6pwXHYGA== Original-Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id DEDC612021C; Fri, 25 Sep 2020 13:51:06 -0400 (EDT) In-Reply-To: <8738l2hode.fsf@gmail.com> (Thierry Volpiatto's message of "Sun, 05 Jan 2014 08:35:57 +0100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:188989 Archived-At: > 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'."