From: Augusto Stoffel <arstoffel@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, 57673@debbugs.gnu.org
Subject: bug#57673: [PATCH] Parse --help messages for pcomplete
Date: Sat, 10 Sep 2022 18:12:31 +0200 [thread overview]
Message-ID: <87sfkzgqds.fsf@gmail.com> (raw)
In-Reply-To: <jwvzgf7fgnb.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sat, 10 Sep 2022 10:32:38 -0400")
On Sat, 10 Sep 2022 at 10:32, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> I've attached a new iteration of the patch. I think the git completion
>> should be pretty usable (but certainly can be refined in the future).
>> I'm also satisfied with the parser, please have a look if you are
>> interested.
>
> LGTM, feel free to push it to `master`.
Sounds good, I'll send a mergeable patch in due time.
>> Next I'd like to think now of a good way to add batches of simpler
>> commands, say all GNU coreutils. This would entail repeating variations
>> of
>>
>> (defun pcomplete/gpg ()
>> "Completion for the GNU Privacy Guard."
>> (while (if (pcomplete-match "\\`-" 0)
>> (pcomplete-here (pcomplete-from-help "gpg --help"
>> :narrow-end "^ -se"))
>> (pcomplete-here (pcomplete-entries)))))
>>
>> over and over, so I was wondering if it makes sense to add a macro to
>> help here. See a suggestion at the end of pcomplete.el.
>
> I do think it makes sense, but I think it doesn't need to be a macro:
Yes, the function is wholly sufficient, except that I don't know how to
make the definitions autoloadable.
I guess there's no performance reasons to autoload these little
definitions, but we would need autoloading to keep the grouping of
commands into the different pcmpl-*.el libraries.
So how to I teach the autoload mechanism to do whatever it needs to do
every time it sees a (define-simple-pcomplete ...) form?
>> +;; What do you think of a macro like this?
>> +(defmacro define-simple-pcomplete (name command &rest args)
>> + "Create `pcomplete' completions for a simple command.
>> +COMMAND and ARGS are as in `pcomplete-from-help'. Completion
>> +candidates for this command will include the parsed arguments as
>> +well as files."
>> + (let* ((namestr (symbol-name name))
>> + (docstring (if-let ((i (string-search "/" namestr)))
>> + (format "Completions for the `%s' command in `%s'."
>> + (substring namestr 0 i)
>> + (substring namestr i))
>> + (format "Completions for the `%s' command." namestr))))
>> + `(defun ,(intern (concat "pcomplete/" namestr)) ()
>> + ,docstring
>> + (pcomplete--simple-command ,command ',args))))
>
> (defun define-simple-pcomplete (name command &rest args)
> "Create `pcomplete' completions for a simple command.
> COMMAND and ARGS are as in `pcomplete-from-help'. Completion
> candidates for this command will include the parsed arguments as
> well as files."
> (let* ((namestr (symbol-name name))
> (docstring (if-let ((i (string-search "/" namestr)))
> (format "Completions for the `%s' command in `%s'."
> (substring namestr 0 i)
> (substring namestr i))
> (format "Completions for the `%s' command." namestr))))
> (defalias (intern (concat "pcomplete/" namestr))
> (lambda ()
> (:documentation docstring)
> (pcomplete--simple-command command args)))))
>
> Also, we may end up with various "simple" solutions, so I'd use a name
> that is more explicit about how it works. E.g. `pcomplete-via-help`?
>
>
> Stefan
next prev parent reply other threads:[~2022-09-10 16:12 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 9:34 bug#57673: [PATCH] Parse --help messages for pcomplete Augusto Stoffel
2022-09-08 12:39 ` Lars Ingebrigtsen
2022-09-08 13:05 ` Augusto Stoffel
2022-09-09 17:02 ` Lars Ingebrigtsen
2022-09-10 9:20 ` Augusto Stoffel
2022-09-08 20:49 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-08 21:53 ` Augusto Stoffel
2022-09-09 2:47 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-10 9:45 ` Augusto Stoffel
2022-09-10 14:32 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-10 16:12 ` Augusto Stoffel [this message]
2022-09-14 19:15 ` Augusto Stoffel
2022-09-14 19:21 ` Lars Ingebrigtsen
2022-09-14 19:41 ` Augusto Stoffel
2022-09-14 19:48 ` Lars Ingebrigtsen
2022-09-14 19:57 ` Augusto Stoffel
2022-09-14 19:59 ` Lars Ingebrigtsen
2022-09-14 20:40 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-09-14 21:11 ` Lars Ingebrigtsen
2022-09-14 21:23 ` Augusto Stoffel
2022-09-14 21:45 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=87sfkzgqds.fsf@gmail.com \
--to=arstoffel@gmail.com \
--cc=57673@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=monnier@iro.umontreal.ca \
/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).