emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master ba42f79: Fix pcomplete completion of things like `xargs` and `sud


From: Stefan Monnier
Subject: master ba42f79: Fix pcomplete completion of things like `xargs` and `sudo` (bug#16197)
Date: Sun, 27 Sep 2020 22:07:19 -0400 (EDT)

branch: master
commit ba42f7932419c3c8b1e23f39c81a1a2dd1b3a154
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Fix pcomplete completion of things like `xargs` and `sudo` (bug#16197)
    
    * lisp/pcmpl-unix.el (pcomplete/xargs): Don't `pcomplete-this` around
    `pcomplete-command-completion-function`.
    (pcomplete/sudo): Make it an alias for `pcomplete/xargs`.
    
    * lisp/shell.el (shell-command-completion-function): Return the
    names from `exec-path` when the command name has no `/`.
---
 lisp/pcmpl-unix.el | 6 +++++-
 lisp/shell.el      | 9 ++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lisp/pcmpl-unix.el b/lisp/pcmpl-unix.el
index 74f45b9..9d346cf 100644
--- a/lisp/pcmpl-unix.el
+++ b/lisp/pcmpl-unix.el
@@ -82,10 +82,14 @@ being via `pcmpl-ssh-known-hosts-file'."
 ;;;###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 9667dab..6129e5e 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -460,9 +460,12 @@ Thus, this does not include the shell's current 
directory.")
 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 via email to

[Prev in Thread] Current Thread [Next in Thread]