diff options
author | Augusto Stoffel <arstoffel@gmail.com> | 2022-09-08 11:09:42 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2022-09-14 21:58:04 +0200 |
commit | a9941269683fe50673d0aa81feefb7a9d3d8a6b9 (patch) | |
tree | 566c9ecd3afb90b58607c71ad794cee14ba7b823 /lisp/pcmpl-gnu.el | |
parent | 05971d2b8d47e69e9585d0d6066b8a607555aa48 (diff) | |
download | emacs-a9941269683fe50673d0aa81feefb7a9d3d8a6b9.tar.gz emacs-a9941269683fe50673d0aa81feefb7a9d3d8a6b9.tar.bz2 emacs-a9941269683fe50673d0aa81feefb7a9d3d8a6b9.zip |
pcomplete: Generate completions from --help messages
* lisp/pcomplete.el (pcomplete-from-help): New function (and hash
table) to get pcomplete candidates from help messages.
(pcomplete-here-using-help): Helper function to define pcomplete for
simple commands
(pcomplete-completions-at-point): Provide annotation-function and
company-docsig properties.
* lisp/pcmpl-git.el: New file, provides pcomplete for Git.
* lisp/pcmpl-gnu.el: Add pcomplete for awk, gpg and gdb, emacs and
emacsclient.
* lisp/pcmpl-linux.el: Add pcomplete for systemctl and journalctl.
* lisp/pcmpl-rpm.el: Add pcomplete for dnf.
* lisp/pcmpl-unix.el: Add pcomplete for sudo and most commands found
in GNU Coreutils.
* lisp/pcmpl-x.el: Add pcomplete for tex, pdftex, latex, pdflatex,
rigrep and rclone.
* test/lisp/pcomplete-tests.el (pcomplete-test-parse-gpg-help,
pcomplete-test-parse-git-help): Tests for the new functions.
Diffstat (limited to 'lisp/pcmpl-gnu.el')
-rw-r--r-- | lisp/pcmpl-gnu.el | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/lisp/pcmpl-gnu.el b/lisp/pcmpl-gnu.el index 3c9bf1ec9d2..cdfde5640a7 100644 --- a/lisp/pcmpl-gnu.el +++ b/lisp/pcmpl-gnu.el @@ -394,6 +394,40 @@ Return the new list." (while (pcomplete-here (pcomplete-dirs) nil #'identity)))) ;;;###autoload -(defalias 'pcomplete/gdb 'pcomplete/xargs) +(defun pcomplete/awk () + "Completion for the `awk' command." + (pcomplete-here-using-help "awk --help" + :margin "\t" + :separator " +" + :description "\0" + :metavar "[=a-z]+")) + +;;;###autoload +(defun pcomplete/gpg () + "Completion for the `gpg` command." + (pcomplete-here-using-help "gpg --help" :narrow-end "^ -se")) + +;;;###autoload +(defun pcomplete/gdb () + "Completion for the `gdb' command." + (while + (cond + ((string= "--args" (pcomplete-arg 1)) + (funcall pcomplete-command-completion-function) + (funcall (or (pcomplete-find-completion-function (pcomplete-arg 1)) + pcomplete-default-completion-function))) + ((string-prefix-p "-" (pcomplete-arg 0)) + (pcomplete-here (pcomplete-from-help "gdb --help"))) + (t (pcomplete-here (pcomplete-entries)))))) + +;;;###autoload +(defun pcomplete/emacs () + "Completion for the `emacs' command." + (pcomplete-here-using-help "emacs --help" :margin "^\\(\\)-")) + +;;;###autoload +(defun pcomplete/emacsclient () + "Completion for the `emacsclient' command." + (pcomplete-here-using-help "emacsclient --help" :margin "^\\(\\)-")) ;;; pcmpl-gnu.el ends here |