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-x.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-x.el')
-rw-r--r-- | lisp/pcmpl-x.el | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lisp/pcmpl-x.el b/lisp/pcmpl-x.el index 261a3d4e27b..1ede867c5fb 100644 --- a/lisp/pcmpl-x.el +++ b/lisp/pcmpl-x.el @@ -28,6 +28,22 @@ (eval-when-compile (require 'cl-lib)) (require 'pcomplete) +;;; TeX + +;;;###autoload +(defun pcomplete/tex () + "Completion for the `tex' command." + (pcomplete-here-using-help "tex --help" + :margin "^\\(?:\\[-no\\]\\)?\\(\\)-")) +;;;###autoload(defalias 'pcomplete/pdftex 'pcomplete/tex) +;;;###autoload(defalias 'pcomplete/latex 'pcomplete/tex) +;;;###autoload(defalias 'pcomplete/pdflatex 'pcomplete/tex) + +;;;###autoload +(defun pcomplete/luatex () + "Completion for the `luatex' command." + (pcomplete-here-using-help "luatex --help")) +;;;###autoload(defalias 'pcomplete/lualatex 'pcomplete/luatex) ;;;; tlmgr - https://www.tug.org/texlive/tlmgr.html @@ -142,6 +158,12 @@ (unless (pcomplete-match "^--" 0) (pcomplete-here* (pcomplete-dirs-or-entries))))))) +;;; Grep-like tools + +;;;###autoload +(defun pcomplete/rg () + "Completion for the `rg' command." + (pcomplete-here-using-help "rg --help")) ;;;; ack - https://betterthangrep.com @@ -288,6 +310,8 @@ long options." (pcmpl-x-ag-options)))) (pcomplete-here* (pcomplete-dirs-or-entries))))) +;;; Borland + ;;;###autoload (defun pcomplete/bcc32 () "Completion function for Borland's C++ compiler." @@ -321,5 +345,24 @@ long options." ;;;###autoload (defalias 'pcomplete/bcc 'pcomplete/bcc32) +;;; Network tools + +;;;###autoload +(defun pcomplete/rclone () + "Completion for the `rclone' command." + (let ((subcmds (pcomplete-from-help "rclone help" + :margin "^ " + :argument "[a-z]+" + :narrow-start "\n\n"))) + (while (not (member (pcomplete-arg 1) subcmds)) + (pcomplete-here (completion-table-merge + subcmds + (pcomplete-from-help "rclone help flags")))) + (let ((subcmd (pcomplete-arg 1))) + (while (if (pcomplete-match "\\`-" 0) + (pcomplete-here (pcomplete-from-help + `("rclone" ,subcmd "--help"))) + (pcomplete-here (pcomplete-entries))))))) + (provide 'pcmpl-x) ;;; pcmpl-x.el ends here |