]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix pcomplete completion of things like `xargs` and `sudo` (bug#16197)
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 28 Sep 2020 02:07:14 +0000 (22:07 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 28 Sep 2020 02:07:14 +0000 (22:07 -0400)
* 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
lisp/shell.el

index 74f45b95233871e3e6592c4cd4d44438283207e6..9d346cfbd22781b849df0a0e667f91a0febda800 100644 (file)
@@ -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)
 
index 9667dab2afdc59692ab23bae5ec2e05482a08bd8..6129e5efc84294bf911374b7e713321d65df8712 100644 (file)
@@ -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'."