unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Karthik Chikmagalur <karthikchikmagalur@gmail.com>
To: 49603@debbugs.gnu.org
Subject: bug#49603: pcomplete completion for xargs (pcomplete/xargs)
Date: Sat, 17 Jul 2021 00:53:18 -0700	[thread overview]
Message-ID: <87pmvh1imp.fsf@gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 968 bytes --]

Hello,

The function "pcomplete/xargs" (in lisp/pcmpl-unix.el) was set up to
treat xargs with the usage pattern

       xargs [command [initial-arguments]]

Whereas the usage of xargs is actually

       xargs [options] [command [initial-arguments]]

So options to xargs itself were not being completed (assuming
pcomplete-default-completion-function is capable of generating these
completions.)

I added this, treating any string that begins with a "-" following xargs
as an xargs argument and the first string that doesn't as the command
being run by xargs. For example,

       xargs -I{} -0 rm -r
       
-I and -0 will be completed as arguments to xargs (using
 pcomplete-default-completion-function) and rm as a command (using pcomplete-command-completion-function).
 
Commit log entry:

* lisp/pcmpl-unix.el (pcomplete/xargs): Add support for completing xargs
options, including the ability to distinguish them from the command
xargs runs.

Karthik Chikmagalur

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: pcmpl-unix-pcomplete-xargs.diff --]
[-- Type: text/x-patch, Size: 716 bytes --]

diff -u /home/karthik/.local/share/git/emacs-src/lisp/pcmpl-unix.el /home/karthik/.local/share/git/emacs-src/lisp/pcmpl-unix-new.el
--- emacs-src/lisp/pcmpl-unix.el	2021-07-02 18:50:29.556608640 -0700
+++ emacs-src/lisp/pcmpl-unix-new.el	2021-07-17 00:35:39.417290007 -0700
@@ -82,7 +82,8 @@
 ;;;###autoload
 (defun pcomplete/xargs ()
   "Completion for `xargs'."
-  ;; FIXME: Add completion of xargs-specific arguments.
+  (while (string-prefix-p "-" (pcomplete-arg 0))
+    (pcomplete-here (funcall pcomplete-default-completion-function)))
   (funcall pcomplete-command-completion-function)
   (funcall (or (pcomplete-find-completion-function (pcomplete-arg 1))
 	       pcomplete-default-completion-function)))



             reply	other threads:[~2021-07-17  7:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-17  7:53 Karthik Chikmagalur [this message]
2021-07-17 14:30 ` bug#49603: pcomplete completion for xargs (pcomplete/xargs) Lars Ingebrigtsen
2021-07-17 21:56   ` Karthik Chikmagalur
2021-07-17 22:32     ` Lars Ingebrigtsen

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=87pmvh1imp.fsf@gmail.com \
    --to=karthikchikmagalur@gmail.com \
    --cc=49603@debbugs.gnu.org \
    /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).