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: Sat, 26 Sep 2020 18:17:33 -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> <87k0wgn0qe.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24700"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Thierry Volpiatto , 16197@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 27 00:18:10 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 1kMIW9-0006KZ-TL for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 27 Sep 2020 00:18:09 +0200 Original-Received: from localhost ([::1]:60548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMIW8-0006ts-VE for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Sep 2020 18:18:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMIW2-0006th-Mt for bug-gnu-emacs@gnu.org; Sat, 26 Sep 2020 18:18:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36356) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kMIW2-0003kf-At for bug-gnu-emacs@gnu.org; Sat, 26 Sep 2020 18:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kMIW2-0004Kr-6f for bug-gnu-emacs@gnu.org; Sat, 26 Sep 2020 18:18: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: Sat, 26 Sep 2020 22:18: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.160115866716644 (code B ref 16197); Sat, 26 Sep 2020 22:18:02 +0000 Original-Received: (at 16197) by debbugs.gnu.org; 26 Sep 2020 22:17:47 +0000 Original-Received: from localhost ([127.0.0.1]:47902 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMIVn-0004KN-8Q for submit@debbugs.gnu.org; Sat, 26 Sep 2020 18:17:47 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:21181) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMIVh-0004K4-L4 for 16197@debbugs.gnu.org; Sat, 26 Sep 2020 18:17:45 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 54306441283; Sat, 26 Sep 2020 18:17:36 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id BB3EC44127D; Sat, 26 Sep 2020 18:17:34 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1601158654; bh=iLFZqrWGGRxvqNvN2qLcxjfwnDF1HCxV/vVFiFS9JJM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=UNg71dcz4+8e+Ej6rakiBAIchMVW1axAde/bEKddI/steBuHtoiYiVgmMMkcpYXG2 XzBfrcn+Pso3A92tMO+Uxy2tqFtGlDqjzZUs0uRwXp8CIqr1su81Dz0dvKHiAced5n uArJ8qWqjd7+IpSjqhYtyvIDgZQkh/P5pmyXh9E4OQ/G49wCo58ZmWZf7pEe6Sguf6 hOpoaMobDT7OQF1VGaNZR333tlifSvuu5UkIySdJm3mWBxOoUU08Bjl559aKG1CBBw qR3khbyGQG03eYleOn77AiZzuM29EXSgZG39oeaOKj8bSsUXmGgrYsZa5ufk2T/KZ/ 1K4q/pozqlDtQ== Original-Received: from alfajor (unknown [45.72.232.131]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 7E91B1202C1; Sat, 26 Sep 2020 18:17:34 -0400 (EDT) In-Reply-To: <87k0wgn0qe.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sat, 26 Sep 2020 15:09:29 +0200") 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:189074 Archived-At: >> 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. > > I think I read somewhere that Thierry is no longer working on Emacs > stuff... Let's see... Oh, here: > > https://news.ycombinator.com/item?id=24449883 > > Hm, that's only about Helm... > > Anyway, this doesn't help with the sudo case, I guess? The sudo case is the same as xargs, so it's a simple matter of duplicating the pcomplete/xargs (or making an alias) as in the patch below. Stefan diff --git a/lisp/pcmpl-unix.el b/lisp/pcmpl-unix.el index dc0d729849..8d4e7ea33d 100644 --- a/lisp/pcmpl-unix.el +++ b/lisp/pcmpl-unix.el @@ -83,10 +83,14 @@ pcomplete/rm ;;;###autoload (defun pcomplete/xargs () "Completion for `xargs'." - (pcomplete-here (funcall pcomplete-command-completion-function)) + ;; FIXME: Add completion of xargs-specific arguments. + (funcall pcomplete-command-completion-function) (funcall (or (pcomplete-find-completion-function (pcomplete-arg 1)) pcomplete-default-completion-function))) +;; FIXME: Add completion of sudo-specific arguments. +(defalias 'pcomplete/sudo #'pcomplete/xargs) + ;;;###autoload (defalias 'pcomplete/time 'pcomplete/xargs) 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'."