Add pcomplete--obarray for isolated completion function dispatch

* lisp/pcomplete.el (pcomplete-define, pcomplete-alias): New macros.
(pcomplete-find-completion-function): Look up in
'pcomplete--obarray' first, then fall back to global obarray.

* lisp/subr.el: (pcomplete--obarray, pcomplete--autoload): Declare these
helpers here in this preloaded file.

* lisp/pcmpl-unix.el: Convert all pcomplete/ defuns and
defalias forms.

* lisp/pcmpl-gnu.el: Likewise.

* lisp/pcmpl-linux.el: Likewise.

* lisp/pcmpl-x.el: Likewise.

* lisp/pcmpl-cvs.el: Likewise.

* lisp/pcmpl-git.el: Likewise.

* lisp/pcmpl-rpm.el: Likewise.

* lisp/erc/erc-pcomplete.el: Likewise.

* lisp/erc/erc-dcc.el: Likewise.

* lisp/erc/erc-notify.el: Likewise.

* lisp/org/org-pcomplete.el: Likewise.

* lisp/eshell/em-alias.el: Likewise.

* lisp/eshell/em-basic.el: Likewise.

* lisp/eshell/esh-var.el: Likewise.

* lisp/ldefs-boot.el: Remove conflicting things.
This commit is contained in:
João Távora 2026-03-12 23:19:13 +00:00
parent c108a28203
commit b13edcd55f
17 changed files with 271 additions and 224 deletions

View file

@ -420,7 +420,7 @@ where FOO is one of CLOSE, GET, SEND, LIST, CHAT, etc."
'erc-cmd-DCC)))
;;;###autoload
(defun pcomplete/erc-mode/DCC ()
(pcomplete-define "erc-mode/DCC" ()
"Provide completion for the /DCC command."
(pcomplete-here (append '("chat" "close" "get" "list")
(when (fboundp 'make-network-process) '("send"))))
@ -1142,9 +1142,9 @@ Possible values are: ask, auto, ignore."
erc-dcc-send-request)))
t)))
(defun pcomplete/erc-mode/CREQ ()
(pcomplete-define "erc-mode/CREQ" ()
(pcomplete-here '("auto" "ask" "ignore")))
(defalias 'pcomplete/erc-mode/SREQ #'pcomplete/erc-mode/CREQ)
(pcomplete-define "erc-mode/SREQ" () (pcomplete/erc-mode/CREQ))
(defvar erc-dcc-chat-filter-functions '(erc-dcc-chat-parse-output)
"Abnormal hook run after parsing (and maybe inserting) a DCC message.

View file

@ -243,7 +243,7 @@ with args, toggle notify status of people."
(&optional postfix))
;;;###autoload
(defun pcomplete/erc-mode/NOTIFY ()
(pcomplete-define "erc-mode/NOTIFY" ()
(require 'erc-pcomplete)
(pcomplete-here (append erc-notify-list (pcomplete-erc-all-nicks))))

View file

@ -103,7 +103,7 @@ for use on `completion-at-point-function'."
;;; Programmable completion logic
(defun pcomplete/erc-mode/complete-command ()
(pcomplete-define "erc-mode/complete-command" ()
(pcomplete-here
(append
(pcomplete-erc-commands)
@ -112,88 +112,88 @@ for use on `completion-at-point-function'."
(defvar erc-pcomplete-ctcp-commands
'("ACTION" "CLIENTINFO" "ECHO" "FINGER" "PING" "TIME" "USERINFO" "VERSION"))
(defun pcomplete/erc-mode/CTCP ()
(pcomplete-define "erc-mode/CTCP" ()
(pcomplete-here (pcomplete-erc-nicks))
(pcomplete-here erc-pcomplete-ctcp-commands))
(defun pcomplete/erc-mode/CLEARTOPIC ()
(pcomplete-define "erc-mode/CLEARTOPIC" ()
(pcomplete-here (pcomplete-erc-channels)))
(defun pcomplete/erc-mode/DEOP ()
(pcomplete-define "erc-mode/DEOP" ()
(while (pcomplete-here (pcomplete-erc-ops))))
(defun pcomplete/erc-mode/DESCRIBE ()
(pcomplete-define "erc-mode/DESCRIBE" ()
(pcomplete-here (pcomplete-erc-nicks)))
(defun pcomplete/erc-mode/IDLE ()
(pcomplete-define "erc-mode/IDLE" ()
(while (pcomplete-here (pcomplete-erc-nicks))))
(defun pcomplete/erc-mode/KICK ()
(pcomplete-define "erc-mode/KICK" ()
(pcomplete-here (pcomplete-erc-channels))
(pcomplete-here (pcomplete-erc-nicks)))
(defun pcomplete/erc-mode/LOAD ()
(pcomplete-define "erc-mode/LOAD" ()
(pcomplete-here (pcomplete-entries)))
(defun pcomplete/erc-mode/MODE ()
(pcomplete-define "erc-mode/MODE" ()
(pcomplete-here (pcomplete-erc-channels))
(while (pcomplete-here (pcomplete-erc-nicks))))
(defun pcomplete/erc-mode/ME ()
(pcomplete-define "erc-mode/ME" ()
(while (pcomplete-here (pcomplete-erc-nicks))))
(defun pcomplete/erc-mode/SAY ()
(pcomplete-define "erc-mode/SAY" ()
(pcomplete-here (pcomplete-erc-nicks))
(pcomplete-here (pcomplete-erc-nicks))
(while (pcomplete-here (pcomplete-erc-nicks))))
(defun pcomplete/erc-mode/MSG ()
(pcomplete-define "erc-mode/MSG" ()
(pcomplete-here (append (pcomplete-erc-all-nicks)
(pcomplete-erc-channels)))
(while (pcomplete-here (pcomplete-erc-nicks))))
(defun pcomplete/erc-mode/NAMES ()
(pcomplete-define "erc-mode/NAMES" ()
(while (pcomplete-here (pcomplete-erc-channels))))
(defalias 'pcomplete/erc-mode/NOTICE #'pcomplete/erc-mode/MSG)
(pcomplete-define "erc-mode/NOTICE" () (pcomplete/erc-mode/MSG))
(defun pcomplete/erc-mode/OP ()
(pcomplete-define "erc-mode/OP" ()
(while (pcomplete-here (pcomplete-erc-not-ops))))
(defun pcomplete/erc-mode/PART ()
(pcomplete-define "erc-mode/PART" ()
(pcomplete-here (pcomplete-erc-channels)))
(defalias 'pcomplete/erc-mode/LEAVE #'pcomplete/erc-mode/PART)
(pcomplete-define "erc-mode/LEAVE" () (pcomplete/erc-mode/PART))
(defun pcomplete/erc-mode/QUERY ()
(pcomplete-define "erc-mode/QUERY" ()
(pcomplete-here (append (pcomplete-erc-all-nicks)
(pcomplete-erc-channels)))
(while (pcomplete-here (pcomplete-erc-nicks)))
)
(defun pcomplete/erc-mode/SOUND ()
(pcomplete-define "erc-mode/SOUND" ()
(while (pcomplete-here (pcomplete-entries))))
(defun pcomplete/erc-mode/TOPIC ()
(pcomplete-define "erc-mode/TOPIC" ()
(pcomplete-here (pcomplete-erc-channels)))
(defun pcomplete/erc-mode/WHOIS ()
(pcomplete-define "erc-mode/WHOIS" ()
(while (pcomplete-here (pcomplete-erc-nicks))))
(defun pcomplete/erc-mode/UNIGNORE ()
(pcomplete-define "erc-mode/UNIGNORE" ()
(pcomplete-here (erc-with-server-buffer erc-ignore-list)))
(defun pcomplete/erc-mode/RECONNECT ()
(pcomplete-define "erc-mode/RECONNECT" ()
(pcomplete-here '("cancel"))
(pcomplete-opt "a"))
(defun pcomplete/erc-mode/BANLIST ()
(pcomplete-define "erc-mode/BANLIST" ()
(pcomplete-opt "f"))
(defalias 'pcomplete/erc-mode/BL #'pcomplete/erc-mode/BANLIST)
(pcomplete-define "erc-mode/BL" () (pcomplete/erc-mode/BANLIST))
(defun pcomplete/erc-mode/MASSUNBAN ()
(pcomplete-define "erc-mode/MASSUNBAN" ()
(pcomplete-opt "f"))
(defalias 'pcomplete/erc-mode/MUB #'pcomplete/erc-mode/MASSUNBAN)
(pcomplete-define "erc-mode/MUB" () (pcomplete/erc-mode/MASSUNBAN))
;;; Functions that provide possible completions.

View file

@ -182,7 +182,7 @@ file named by `eshell-aliases-file'.")
(defvar pcomplete-stub)
(autoload 'pcomplete-here "pcomplete")
(defun pcomplete/eshell-mode/alias ()
(pcomplete-define "eshell-mode/alias" ()
"Completion function for Eshell's `alias' command."
(pcomplete-here (eshell-alias-completions pcomplete-stub)))

View file

@ -220,7 +220,7 @@ are:
(dolist (kind eshell-debug-command)
(eshell-printn (symbol-name kind))))))
(defun pcomplete/eshell-mode/eshell-debug ()
(pcomplete-define "eshell-mode/eshell-debug" ()
"Completion for the `debug' command."
(while (pcomplete-here '("error" "form" "process"))))

View file

@ -379,7 +379,7 @@ This function is explicit for adding to `eshell-parse-argument-hook'."
(eshell-set-variable (match-string 1 set)
(match-string 2 set)))))
(defun pcomplete/eshell-mode/export ()
(pcomplete-define "eshell-mode/export" ()
"Completion function for Eshell's `export'."
(while (pcomplete-here
(if eshell-complete-export-definition
@ -393,7 +393,7 @@ the values of nil for each."
(dolist (arg args)
(eshell-set-variable arg nil)))
(defun pcomplete/eshell-mode/unset ()
(pcomplete-define "eshell-mode/unset" ()
"Completion function for Eshell's `unset'."
(while (pcomplete-here (eshell-envvar-names))))
@ -405,7 +405,7 @@ the values of nil for each."
args (cddr args)))
last-value))
(defun pcomplete/eshell-mode/set ()
(pcomplete-define "eshell-mode/set" ()
"Completion function for Eshell's `set'."
(while (pcomplete-here (eshell-envvar-names))))
@ -419,7 +419,7 @@ the values of nil for each."
args (cddr args))))
last-value))
(defun pcomplete/eshell-mode/setq ()
(pcomplete-define "eshell-mode/setq" ()
"Completion function for Eshell's `setq'."
(while (and (pcomplete-here (all-completions pcomplete-stub
obarray #'boundp))

View file

@ -25469,7 +25469,6 @@ for the result of evaluating EXP (first arg to `pcase').
(autoload 'pcomplete/cd "pcmpl-unix"
"Completion for `cd'.")
(defalias 'pcomplete/pushd 'pcomplete/cd)
(autoload 'pcomplete/rmdir "pcmpl-unix"
"Completion for `rmdir'.")
(autoload 'pcomplete/rm "pcmpl-unix"
@ -25490,7 +25489,6 @@ for the result of evaluating EXP (first arg to `pcase').
"Completion for the `od' command.")
(autoload 'pcomplete/base32 "pcmpl-unix"
"Completion for the `base32' and `base64' commands.")
(defalias 'pcomplete/base64 'pcomplete/base32)
(autoload 'pcomplete/basenc "pcmpl-unix"
"Completion for the `basenc' command.")
(autoload 'pcomplete/fmt "pcmpl-unix"
@ -25517,11 +25515,6 @@ for the result of evaluating EXP (first arg to `pcase').
"Completion for the `b2sum' command.")
(autoload 'pcomplete/md5sum "pcmpl-unix"
"Completion for checksum commands.")
(defalias 'pcomplete/sha1sum 'pcomplete/md5sum)
(defalias 'pcomplete/sha224sum 'pcomplete/md5sum)
(defalias 'pcomplete/sha256sum 'pcomplete/md5sum)
(defalias 'pcomplete/sha384sum 'pcomplete/md5sum)
(defalias 'pcomplete/sha512sum 'pcomplete/md5sum)
(autoload 'pcomplete/sort "pcmpl-unix"
"Completion for the `sort' command.")
(autoload 'pcomplete/shuf "pcmpl-unix"
@ -25548,8 +25541,6 @@ for the result of evaluating EXP (first arg to `pcase').
"Completion for the `unexpand' command.")
(autoload 'pcomplete/ls "pcmpl-unix"
"Completion for the `ls' command.")
(defalias 'pcomplete/dir 'pcomplete/ls)
(defalias 'pcomplete/vdir 'pcomplete/ls)
(autoload 'pcomplete/cp "pcmpl-unix"
"Completion for the `cp' command.")
(autoload 'pcomplete/dd "pcmpl-unix"
@ -25592,7 +25583,6 @@ for the result of evaluating EXP (first arg to `pcase').
"Completion for the `echo' command.")
(autoload 'pcomplete/test "pcmpl-unix"
"Completion for the `test' command.")
(defalias (intern "pcomplete/[") 'pcomplete/test)
(autoload 'pcomplete/tee "pcmpl-unix"
"Completion for the `tee' command.")
(autoload 'pcomplete/basename "pcmpl-unix"
@ -25643,7 +25633,6 @@ for the result of evaluating EXP (first arg to `pcase').
"Completion for the `seq' command.")
(autoload 'pcomplete/ssh "pcmpl-unix"
"Completion rules for the `ssh' command.")
(defalias 'pcomplete/rsh #'pcomplete/ssh)
(autoload 'pcomplete/scp "pcmpl-unix"
"Completion rules for the `scp' command.
Includes files as well as host names followed by a colon.")
@ -25659,12 +25648,8 @@ Includes files as well as host names followed by a colon.")
(autoload 'pcomplete/tex "pcmpl-x"
"Completion for the `tex' command.")
(defalias 'pcomplete/pdftex 'pcomplete/tex)
(defalias 'pcomplete/latex 'pcomplete/tex)
(defalias 'pcomplete/pdflatex 'pcomplete/tex)
(autoload 'pcomplete/luatex "pcmpl-x"
"Completion for the `luatex' command.")
(defalias 'pcomplete/lualatex 'pcomplete/luatex)
(autoload 'pcomplete/tlmgr "pcmpl-x"
"Completion for the `tlmgr' command.")
(autoload 'pcomplete/rg "pcmpl-x"
@ -25673,12 +25658,10 @@ Includes files as well as host names followed by a colon.")
"Completion for the `ack' command.
Start an argument with `-' to complete short options and `--' for
long options.")
(defalias 'pcomplete/ack-grep 'pcomplete/ack)
(autoload 'pcomplete/ag "pcmpl-x"
"Completion for the `ag' command.")
(autoload 'pcomplete/bcc32 "pcmpl-x"
"Completion function for Borland's C++ compiler.")
(defalias 'pcomplete/bcc 'pcomplete/bcc32)
(autoload 'pcomplete/rclone "pcmpl-x"
"Completion for the `rclone' command.")
(register-definition-prefixes "pcmpl-x" '("pcmpl-x-"))

View file

@ -210,7 +210,7 @@ When completing for #+STARTUP, for example, this function returns
;;; Completion functions
(defun pcomplete/org-mode/file-option ()
(pcomplete-define "org-mode/file-option" ()
"Complete against all valid file options."
(require 'org-element)
(pcomplete-here
@ -237,51 +237,51 @@ When completing for #+STARTUP, for example, this function returns
(org-get-export-keywords))))
(substring pcomplete-stub 2)))
(defun pcomplete/org-mode/file-option/author ()
(pcomplete-define "org-mode/file-option/author" ()
"Complete arguments for the #+AUTHOR file option."
(pcomplete-here (list user-full-name)))
(defun pcomplete/org-mode/file-option/date ()
(pcomplete-define "org-mode/file-option/date" ()
"Complete arguments for the #+DATE file option."
(pcomplete-here (list (format-time-string (org-time-stamp-format)))))
(defun pcomplete/org-mode/file-option/email ()
(pcomplete-define "org-mode/file-option/email" ()
"Complete arguments for the #+EMAIL file option."
(pcomplete-here (list user-mail-address)))
(defun pcomplete/org-mode/file-option/exclude_tags ()
(pcomplete-define "org-mode/file-option/exclude_tags" ()
"Complete arguments for the #+EXCLUDE_TAGS file option."
(require 'ox)
(pcomplete-here
(and org-export-exclude-tags
(list (mapconcat #'identity org-export-exclude-tags " ")))))
(defun pcomplete/org-mode/file-option/filetags ()
(pcomplete-define "org-mode/file-option/filetags" ()
"Complete arguments for the #+FILETAGS file option."
(pcomplete-here (and org-file-tags (mapconcat #'identity org-file-tags " "))))
(defun pcomplete/org-mode/file-option/language ()
(pcomplete-define "org-mode/file-option/language" ()
"Complete arguments for the #+LANGUAGE file option."
(require 'ox)
(pcomplete-here
(pcomplete-uniquify-list
(list org-export-default-language "en"))))
(defun pcomplete/org-mode/file-option/priorities ()
(pcomplete-define "org-mode/file-option/priorities" ()
"Complete arguments for the #+PRIORITIES file option."
(pcomplete-here (list (format "%c %c %c"
org-priority-highest
org-priority-lowest
org-priority-default))))
(defun pcomplete/org-mode/file-option/select_tags ()
(pcomplete-define "org-mode/file-option/select_tags" ()
"Complete arguments for the #+SELECT_TAGS file option."
(require 'ox)
(pcomplete-here
(and org-export-select-tags
(list (mapconcat #'identity org-export-select-tags " ")))))
(defun pcomplete/org-mode/file-option/startup ()
(pcomplete-define "org-mode/file-option/startup" ()
"Complete arguments for the #+STARTUP file option."
(while (pcomplete-here
(let ((opts (pcomplete-uniquify-list
@ -294,12 +294,12 @@ When completing for #+STARTUP, for example, this function returns
(setq opts (delete "showstars" opts)))))
opts))))
(defun pcomplete/org-mode/file-option/tags ()
(pcomplete-define "org-mode/file-option/tags" ()
"Complete arguments for the #+TAGS file option."
(pcomplete-here
(list (org-tag-alist-to-string org-current-tag-alist))))
(defun pcomplete/org-mode/file-option/title ()
(pcomplete-define "org-mode/file-option/title" ()
"Complete arguments for the #+TITLE file option."
(pcomplete-here
(let ((visited-file (buffer-file-name (buffer-base-buffer))))
@ -309,7 +309,7 @@ When completing for #+STARTUP, for example, this function returns
(buffer-name (buffer-base-buffer)))))))
(defun pcomplete/org-mode/file-option/options ()
(pcomplete-define "org-mode/file-option/options" ()
"Complete arguments for the #+OPTIONS file option."
(while (pcomplete-here
(pcomplete-uniquify-list
@ -328,21 +328,21 @@ When completing for #+STARTUP, for example, this function returns
(when item (push (concat item ":") items)))))
items))))))
(defun pcomplete/org-mode/file-option/infojs_opt ()
(pcomplete-define "org-mode/file-option/infojs_opt" ()
"Complete arguments for the #+INFOJS_OPT file option."
(while (pcomplete-here
(pcomplete-uniquify-list
(mapcar (lambda (item) (format "%s:" (car item)))
(bound-and-true-p org-html-infojs-opts-table))))))
(defun pcomplete/org-mode/file-option/bind ()
(pcomplete-define "org-mode/file-option/bind" ()
"Complete arguments for the #+BIND file option, which are variable names."
(let (vars)
(mapatoms
(lambda (a) (when (boundp a) (setq vars (cons (symbol-name a) vars)))))
(pcomplete-here vars)))
(defun pcomplete/org-mode/link ()
(pcomplete-define "org-mode/link" ()
"Complete against defined #+LINK patterns."
(pcomplete-here
(pcomplete-uniquify-list
@ -351,7 +351,7 @@ When completing for #+STARTUP, for example, this function returns
(append org-link-abbrev-alist-local
org-link-abbrev-alist))))))
(defun pcomplete/org-mode/tex ()
(pcomplete-define "org-mode/tex" ()
"Complete against TeX-style HTML entity names."
(require 'org-entities)
(while (pcomplete-here
@ -359,11 +359,11 @@ When completing for #+STARTUP, for example, this function returns
(remove nil (mapcar #'car-safe org-entities)))
(substring pcomplete-stub 1))))
(defun pcomplete/org-mode/todo ()
(pcomplete-define "org-mode/todo" ()
"Complete against known TODO keywords."
(pcomplete-here (pcomplete-uniquify-list (copy-sequence org-todo-keywords-1))))
(defun pcomplete/org-mode/searchhead ()
(pcomplete-define "org-mode/searchhead" ()
"Complete against all headings.
This needs more work, to handle headings with lots of spaces in them."
(while (pcomplete-here
@ -376,7 +376,7 @@ This needs more work, to handle headings with lots of spaces in them."
(push (substring (org-link-heading-search-string) 1) tbl))
(pcomplete-uniquify-list tbl))))))
(defun pcomplete/org-mode/tag ()
(pcomplete-define "org-mode/tag" ()
"Complete a tag name. Omit tags already set."
(while (pcomplete-here
(mapcar (lambda (x) (concat x ":"))
@ -393,7 +393,7 @@ This needs more work, to handle headings with lots of spaces in them."
(substring pcomplete-stub (match-end 0)))
t)))
(defun pcomplete/org-mode/drawer ()
(pcomplete-define "org-mode/drawer" ()
"Complete a drawer name, including \"PROPERTIES\"."
(pcomplete-here
(org-pcomplete-case-double
@ -409,7 +409,7 @@ This needs more work, to handle headings with lots of spaces in them."
(pcomplete-uniquify-list names))))
(substring pcomplete-stub 1))) ;remove initial colon
(defun pcomplete/org-mode/prop ()
(pcomplete-define "org-mode/prop" ()
"Complete a property name. Omit properties already set."
(pcomplete-here
(org-pcomplete-case-double
@ -422,7 +422,7 @@ This needs more work, to handle headings with lots of spaces in them."
lst)))
(substring pcomplete-stub 1)))
(defun pcomplete/org-mode/block-option/src ()
(pcomplete-define "org-mode/block-option/src" ()
"Complete the arguments of a source block.
Complete a language in the first field, the header arguments and
switches."
@ -445,7 +445,7 @@ switches."
headers)
'("-n" "-r" "-l"))))))
(defun pcomplete/org-mode/block-option/clocktable ()
(pcomplete-define "org-mode/block-option/clocktable" ()
"Complete keywords in a clocktable line."
(while (pcomplete-here '(":maxlevel" ":scope" ":lang"
":tstart" ":tend" ":block" ":step"

View file

@ -43,7 +43,7 @@
;; Functions:
;;;###autoload
(defun pcomplete/cvs ()
(pcomplete-define "cvs" ()
"Completion rules for the `cvs' command."
(let ((pcomplete-help "(cvs)Invoking CVS"))
(pcomplete-opt "HQqrwlntvfab/T/e*d/z?s")

View file

@ -59,7 +59,7 @@ Files listed by `git ls-files ARGS' satisfy the predicate."
(vc-git-revision-table nil))))
;;;###autoload
(defun pcomplete/git ()
(pcomplete-define "git" ()
"Completion for the `git' command."
(let ((subcommands (pcomplete-from-help `(,vc-git-program "help" "-a")
:margin "^\\( +\\)[a-z]"

View file

@ -48,7 +48,7 @@
;; Functions:
;;;###autoload
(defun pcomplete/gzip ()
(pcomplete-define "gzip" ()
"Completion for `gzip'."
(let ((pcomplete-help "(gzip)"))
(pcomplete-opt "cdfhlLnNqrStvV123456789")
@ -75,7 +75,7 @@
(and (not unzip-p) (not zipped)))))))))
;;;###autoload
(defun pcomplete/bzip2 ()
(pcomplete-define "bzip2" ()
"Completion for `bzip2'."
(pcomplete-opt "hdzkftcqvLVs123456789")
(while (pcomplete-here
@ -99,7 +99,7 @@
(and (not unzip-p) (not zipped))))))))
;;;###autoload
(defun pcomplete/make ()
(pcomplete-define "make" ()
"Completion for GNU `make'."
(let ((pcomplete-help "(make)Top"))
(pcomplete-opt "bmC/def(pcmpl-gnu-makefile-names)hiI/j?kl?no.pqrsStvwW.")
@ -265,7 +265,7 @@ Return the new list."
"--volno-file="))
;;;###autoload
(defun pcomplete/tar ()
(pcomplete-define "tar" ()
"Completion for the GNU tar utility."
;; options that end in an equal sign will want further completion...
(let (saw-option complete-within)
@ -344,7 +344,7 @@ Return the new list."
;;;###autoload
(defun pcomplete/find ()
(pcomplete-define "find" ()
"Completion for the GNU find utility."
(let ((prec (pcomplete-arg 'last -1)))
(cond ((and (pcomplete-match "^-" 'last)
@ -379,7 +379,7 @@ Return the new list."
(while (pcomplete-here (pcomplete-dirs) nil #'identity))))
;;;###autoload
(defun pcomplete/awk ()
(pcomplete-define "awk" ()
"Completion for the `awk' command."
(pcomplete-here-using-help "awk --help"
:margin "\t"
@ -388,12 +388,12 @@ Return the new list."
:metavar "[=a-z]+"))
;;;###autoload
(defun pcomplete/gpg ()
(pcomplete-define "gpg" ()
"Completion for the `gpg` command."
(pcomplete-here-using-help "gpg --help" :narrow-end "^ -se"))
;;;###autoload
(defun pcomplete/gdb ()
(pcomplete-define "gdb" ()
"Completion for the `gdb' command."
(while
(cond
@ -406,12 +406,12 @@ Return the new list."
(t (pcomplete-here (pcomplete-entries))))))
;;;###autoload
(defun pcomplete/emacs ()
(pcomplete-define "emacs" ()
"Completion for the `emacs' command."
(pcomplete-here-using-help "emacs --help" :margin "^\\(\\)-"))
;;;###autoload
(defun pcomplete/emacsclient ()
(pcomplete-define "emacsclient" ()
"Completion for the `emacsclient' command."
(pcomplete-here-using-help "emacsclient --help" :margin "^\\(\\)-"))

View file

@ -35,7 +35,7 @@
;; Functions:
;;;###autoload
(defun pcomplete/kill ()
(pcomplete-define "kill" ()
"Completion for GNU/Linux `kill', using /proc filesystem."
(if (pcomplete-match "^-\\(.*\\)" 0)
(pcomplete-here
@ -49,14 +49,14 @@
nil #'identity)))
;;;###autoload
(defun pcomplete/umount ()
(pcomplete-define "umount" ()
"Completion for GNU/Linux `umount'."
(pcomplete-opt "hVafrnvt(pcmpl-linux-fs-types)")
(while (pcomplete-here (pcmpl-linux-mounted-directories)
nil #'identity)))
;;;###autoload
(defun pcomplete/mount ()
(pcomplete-define "mount" ()
"Completion for GNU/Linux `mount'."
(pcomplete-opt "hVanfFrsvwt(pcmpl-linux-fs-types)o?L?U?")
(while (pcomplete-here (pcomplete-entries) nil #'identity)))
@ -139,7 +139,7 @@ Test is done using `equal'."
(nreverse result))))
;;;###autoload
(defun pcomplete/systemctl ()
(pcomplete-define "systemctl" ()
"Completion for the `systemctl' command."
(let ((subcmds (pcomplete-from-help
"systemctl --help"
@ -171,7 +171,7 @@ Test is done using `equal'."
(pcomplete-entries)))))))))
;;;###autoload
(defun pcomplete/journalctl ()
(pcomplete-define "journalctl" ()
"Completion for the `journalctl' command."
(while (if (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "journalctl --help"

View file

@ -102,7 +102,7 @@
(pcomplete-dirs-or-entries "\\.rpm\\'"))
;;;###autoload
(defun pcomplete/rpm ()
(pcomplete-define "rpm" ()
"Completion for the `rpm' command."
;; Originally taken from the output of `rpm --help' on a Red Hat 6.1 system.
(let (mode)
@ -390,7 +390,7 @@ STATUS should be one of --available or --installed."
status)))
;;;###autoload
(defun pcomplete/dnf ()
(pcomplete-define "dnf" ()
"Completion for the `dnf' command."
(let ((subcmds (pcomplete-from-help "dnf --help"
:margin (rx bol (group (* " "))

View file

@ -59,27 +59,27 @@ being via `pcmpl-ssh-known-hosts-file'."
;;; Shell builtins and core utilities
;;;###autoload
(defun pcomplete/cd ()
(pcomplete-define "cd" ()
"Completion for `cd'."
(while (pcomplete-here (pcomplete-dirs))))
;;;###autoload
(defalias 'pcomplete/pushd 'pcomplete/cd)
(pcomplete-alias "pushd" "cd")
;;;###autoload
(defun pcomplete/rmdir ()
(pcomplete-define "rmdir" ()
"Completion for `rmdir'."
(while (if (string-prefix-p "-" (pcomplete-arg))
(pcomplete-here (pcomplete-from-help "rmdir --help"))
(pcomplete-here (pcomplete-dirs)))))
;;;###autoload
(defun pcomplete/rm ()
(pcomplete-define "rm" ()
"Completion for the `rm' command."
(pcomplete-here-using-help "rm --help"))
;;;###autoload
(defun pcomplete/xargs ()
(pcomplete-define "xargs" ()
"Completion for `xargs'."
(while (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "xargs --help"))
@ -89,7 +89,7 @@ being via `pcmpl-ssh-known-hosts-file'."
pcomplete-default-completion-function)))
;;;###autoload
(defun pcomplete/time ()
(pcomplete-define "time" ()
"Completion for the `time' command."
(pcomplete-opt "p")
(funcall pcomplete-command-completion-function)
@ -97,7 +97,7 @@ being via `pcmpl-ssh-known-hosts-file'."
pcomplete-default-completion-function)))
;;;###autoload
(defun pcomplete/which ()
(pcomplete-define "which" ()
"Completion for `which'."
(while (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "which --help")))
@ -133,176 +133,191 @@ documentation), this function returns nil."
(pcmpl-unix-read-passwd-file pcmpl-unix-passwd-file)))
;;;###autoload
(defun pcomplete/cat ()
(pcomplete-define "cat" ()
"Completion for the `cat' command."
(pcomplete-here-using-help "cat --help"))
;;;###autoload
(defun pcomplete/tac ()
(pcomplete-define "tac" ()
"Completion for the `tac' command."
(pcomplete-here-using-help "tac --help"))
;;;###autoload
(defun pcomplete/nl ()
(pcomplete-define "nl" ()
"Completion for the `nl' command."
(pcomplete-here-using-help "nl --help"))
;;;###autoload
(defun pcomplete/od ()
(pcomplete-define "od" ()
"Completion for the `od' command."
(pcomplete-here-using-help "od --help"))
;;;###autoload
(defun pcomplete/base32 ()
(pcomplete-define "base32" ()
"Completion for the `base32' and `base64' commands."
(pcomplete-here-using-help "base32 --help"))
;;;###autoload
(defalias 'pcomplete/base64 'pcomplete/base32)
;;;###autoload
(defun pcomplete/basenc ()
(pcomplete-alias "base64" "base32")
;;;###autoload
(pcomplete-define "basenc" ()
"Completion for the `basenc' command."
(pcomplete-here-using-help "basenc --help"))
;;;###autoload
(defun pcomplete/fmt ()
(pcomplete-define "fmt" ()
"Completion for the `fmt' command."
(pcomplete-here-using-help "fmt --help"))
;;;###autoload
(defun pcomplete/pr ()
(pcomplete-define "pr" ()
"Completion for the `pr' command."
(pcomplete-here-using-help "pr --help"))
;;;###autoload
(defun pcomplete/fold ()
(pcomplete-define "fold" ()
"Completion for the `fold' command."
(pcomplete-here-using-help "fold --help"))
;;;###autoload
(defun pcomplete/head ()
(pcomplete-define "head" ()
"Completion for the `head' command."
(pcomplete-here-using-help "head --help"))
;;;###autoload
(defun pcomplete/tail ()
(pcomplete-define "tail" ()
"Completion for the `tail' command."
(pcomplete-here-using-help "tail --help"))
;;;###autoload
(defun pcomplete/split ()
(pcomplete-define "split" ()
"Completion for the `split' command."
(pcomplete-here-using-help "split --help"))
;;;###autoload
(defun pcomplete/csplit ()
(pcomplete-define "csplit" ()
"Completion for the `csplit' command."
(pcomplete-here-using-help "csplit --help"))
;;;###autoload
(defun pcomplete/wc ()
(pcomplete-define "wc" ()
"Completion for the `wc' command."
(pcomplete-here-using-help "wc --help"))
;;;###autoload
(defun pcomplete/sum ()
(pcomplete-define "sum" ()
"Completion for the `sum' command."
(pcomplete-here-using-help "sum --help"))
;;;###autoload
(defun pcomplete/cksum ()
(pcomplete-define "cksum" ()
"Completion for the `cksum' command."
(pcomplete-here-using-help "cksum --help"))
;;;###autoload
(defun pcomplete/b2sum ()
(pcomplete-define "b2sum" ()
"Completion for the `b2sum' command."
(pcomplete-here-using-help "b2sum --help"))
;;;###autoload
(defun pcomplete/md5sum ()
(pcomplete-define "md5sum" ()
"Completion for checksum commands."
(pcomplete-here-using-help "md5sum --help"))
;;;###autoload(defalias 'pcomplete/sha1sum 'pcomplete/md5sum)
;;;###autoload(defalias 'pcomplete/sha224sum 'pcomplete/md5sum)
;;;###autoload(defalias 'pcomplete/sha256sum 'pcomplete/md5sum)
;;;###autoload(defalias 'pcomplete/sha384sum 'pcomplete/md5sum)
;;;###autoload(defalias 'pcomplete/sha512sum 'pcomplete/md5sum)
;;;###autoload
(defun pcomplete/sort ()
(pcomplete-alias "sha1sum" "md5sum")
;;;###autoload
(pcomplete-alias "sha224sum" "md5sum")
;;;###autoload
(pcomplete-alias "sha256sum" "md5sum")
;;;###autoload
(pcomplete-alias "sha384sum" "md5sum")
;;;###autoload
(pcomplete-alias "sha512sum" "md5sum" )
;;;###autoload
(pcomplete-define "sort" ()
"Completion for the `sort' command."
(pcomplete-here-using-help "sort --help"))
;;;###autoload
(defun pcomplete/shuf ()
(pcomplete-define "shuf" ()
"Completion for the `shuf' command."
(pcomplete-here-using-help "shuf --help"))
;;;###autoload
(defun pcomplete/uniq ()
(pcomplete-define "uniq" ()
"Completion for the `uniq' command."
(pcomplete-here-using-help "uniq --help"))
;;;###autoload
(defun pcomplete/comm ()
(pcomplete-define "comm" ()
"Completion for the `comm' command."
(pcomplete-here-using-help "comm --help"))
;;;###autoload
(defun pcomplete/ptx ()
(pcomplete-define "ptx" ()
"Completion for the `ptx' command."
(pcomplete-here-using-help "ptx --help"))
;;;###autoload
(defun pcomplete/tsort ()
(pcomplete-define "tsort" ()
"Completion for the `tsort' command."
(pcomplete-here-using-help "tsort --help"))
;;;###autoload
(defun pcomplete/cut ()
(pcomplete-define "cut" ()
"Completion for the `cut' command."
(pcomplete-here-using-help "cut --help"))
;;;###autoload
(defun pcomplete/paste ()
(pcomplete-define "paste" ()
"Completion for the `paste' command."
(pcomplete-here-using-help "paste --help"))
;;;###autoload
(defun pcomplete/join ()
(pcomplete-define "join" ()
"Completion for the `join' command."
(pcomplete-here-using-help "join --help"))
;;;###autoload
(defun pcomplete/tr ()
(pcomplete-define "tr" ()
"Completion for the `tr' command."
(pcomplete-here-using-help "tr --help"))
;;;###autoload
(defun pcomplete/expand ()
(pcomplete-define "expand" ()
"Completion for the `expand' command."
(pcomplete-here-using-help "expand --help"))
;;;###autoload
(defun pcomplete/unexpand ()
(pcomplete-define "unexpand" ()
"Completion for the `unexpand' command."
(pcomplete-here-using-help "unexpand --help"))
;;;###autoload
(defun pcomplete/ls ()
(pcomplete-define "ls" ()
"Completion for the `ls' command."
(pcomplete-here-using-help "ls --help"))
;;;###autoload(defalias 'pcomplete/dir 'pcomplete/ls)
;;;###autoload(defalias 'pcomplete/vdir 'pcomplete/ls)
;;;###autoload
(defun pcomplete/cp ()
(pcomplete-alias "dir" "ls")
;;;###autoload
(pcomplete-alias "vdir" "ls")
;;;###autoload
(pcomplete-define "cp" ()
"Completion for the `cp' command."
(pcomplete-here-using-help "cp --help"))
;;;###autoload
(defun pcomplete/dd ()
(pcomplete-define "dd" ()
"Completion for the `dd' command."
(let ((operands (pcomplete-from-help "dd --help"
:argument "[a-z]+="
@ -315,47 +330,47 @@ documentation), this function returns nil."
(t (pcomplete-here operands))))))
;;;###autoload
(defun pcomplete/install ()
(pcomplete-define "install" ()
"Completion for the `install' command."
(pcomplete-here-using-help "install --help"))
;;;###autoload
(defun pcomplete/mv ()
(pcomplete-define "mv" ()
"Completion for the `mv' command."
(pcomplete-here-using-help "mv --help"))
;;;###autoload
(defun pcomplete/shred ()
(pcomplete-define "shred" ()
"Completion for the `shred' command."
(pcomplete-here-using-help "shred --help"))
;;;###autoload
(defun pcomplete/ln ()
(pcomplete-define "ln" ()
"Completion for the `ln' command."
(pcomplete-here-using-help "ln --help"))
;;;###autoload
(defun pcomplete/mkdir ()
(pcomplete-define "mkdir" ()
"Completion for the `mkdir' command."
(pcomplete-here-using-help "mkdir --help"))
;;;###autoload
(defun pcomplete/mkfifo ()
(pcomplete-define "mkfifo" ()
"Completion for the `mkfifo' command."
(pcomplete-here-using-help "mkfifo --help"))
;;;###autoload
(defun pcomplete/mknod ()
(pcomplete-define "mknod" ()
"Completion for the `mknod' command."
(pcomplete-here-using-help "mknod --help"))
;;;###autoload
(defun pcomplete/readlink ()
(pcomplete-define "readlink" ()
"Completion for the `readlink' command."
(pcomplete-here-using-help "readlink --help"))
;;;###autoload
(defun pcomplete/chown ()
(pcomplete-define "chown" ()
"Completion for the `chown' command."
(while (pcomplete-match "\\`-" 0)
(pcomplete-here (pcomplete-from-help "chown --help")))
@ -368,7 +383,7 @@ documentation), this function returns nil."
(while (pcomplete-here (pcomplete-entries))))
;;;###autoload
(defun pcomplete/chgrp ()
(pcomplete-define "chgrp" ()
"Completion for the `chgrp' command."
(while (pcomplete-match "\\`-" 0)
(pcomplete-here (pcomplete-from-help "chgrp --help")))
@ -376,131 +391,132 @@ documentation), this function returns nil."
(while (pcomplete-here (pcomplete-entries))))
;;;###autoload
(defun pcomplete/chmod ()
(pcomplete-define "chmod" ()
"Completion for the `chmod' command."
(pcomplete-here-using-help "chmod --help"))
;;;###autoload
(defun pcomplete/touch ()
(pcomplete-define "touch" ()
"Completion for the `touch' command."
(pcomplete-here-using-help "touch --help"))
;;;###autoload
(defun pcomplete/df ()
(pcomplete-define "df" ()
"Completion for the `df' command."
(pcomplete-here-using-help "df --help"))
;;;###autoload
(defun pcomplete/du ()
(pcomplete-define "du" ()
"Completion for the `du' command."
(pcomplete-here-using-help "du --help"))
;;;###autoload
(defun pcomplete/stat ()
(pcomplete-define "stat" ()
"Completion for the `stat' command."
(pcomplete-here-using-help "stat --help"))
;;;###autoload
(defun pcomplete/sync ()
(pcomplete-define "sync" ()
"Completion for the `sync' command."
(pcomplete-here-using-help "sync --help"))
;;;###autoload
(defun pcomplete/truncate ()
(pcomplete-define "truncate" ()
"Completion for the `truncate' command."
(pcomplete-here-using-help "truncate --help"))
;;;###autoload
(defun pcomplete/echo ()
(pcomplete-define "echo" ()
"Completion for the `echo' command."
(pcomplete-here-using-help '("echo" "--help")))
;;;###autoload
(defun pcomplete/test ()
(pcomplete-define "test" ()
"Completion for the `test' command."
(pcomplete-here-using-help '("[" "--help")
:margin "^ +\\([A-Z]+1 \\)?"))
;;;###autoload(defalias (intern "pcomplete/[") 'pcomplete/test)
;;;###autoload
(pcomplete-alias "[" "test")
;;;###autoload
(defun pcomplete/tee ()
(pcomplete-define "tee" ()
"Completion for the `tee' command."
(pcomplete-here-using-help "tee --help"))
;;;###autoload
(defun pcomplete/basename ()
(pcomplete-define "basename" ()
"Completion for the `basename' command."
(pcomplete-here-using-help "basename --help"))
;;;###autoload
(defun pcomplete/dirname ()
(pcomplete-define "dirname" ()
"Completion for the `dirname' command."
(pcomplete-here-using-help "dirname --help"))
;;;###autoload
(defun pcomplete/pathchk ()
(pcomplete-define "pathchk" ()
"Completion for the `pathchk' command."
(pcomplete-here-using-help "pathchk --help"))
;;;###autoload
(defun pcomplete/mktemp ()
(pcomplete-define "mktemp" ()
"Completion for the `mktemp' command."
(pcomplete-here-using-help "mktemp --help"))
;;;###autoload
(defun pcomplete/realpath ()
(pcomplete-define "realpath" ()
"Completion for the `realpath' command."
(pcomplete-here-using-help "realpath --help"))
;;;###autoload
(defun pcomplete/id ()
(pcomplete-define "id" ()
"Completion for the `id' command."
(while (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "id --help")))
(while (pcomplete-here (pcmpl-unix-user-names))))
;;;###autoload
(defun pcomplete/groups ()
(pcomplete-define "groups" ()
"Completion for the `groups' command."
(while (pcomplete-here (pcmpl-unix-user-names))))
;;;###autoload
(defun pcomplete/who ()
(pcomplete-define "who" ()
"Completion for the `who' command."
(pcomplete-here-using-help "who --help"))
;;;###autoload
(defun pcomplete/date ()
(pcomplete-define "date" ()
"Completion for the `date' command."
(pcomplete-here-using-help "date --help"))
;;;###autoload
(defun pcomplete/nproc ()
(pcomplete-define "nproc" ()
"Completion for the `nproc' command."
(pcomplete-here-using-help "nproc --help"))
;;;###autoload
(defun pcomplete/uname ()
(pcomplete-define "uname" ()
"Completion for the `uname' command."
(pcomplete-here-using-help "uname --help"))
;;;###autoload
(defun pcomplete/hostname ()
(pcomplete-define "hostname" ()
"Completion for the `hostname' command."
(pcomplete-here-using-help "hostname --help"))
;;;###autoload
(defun pcomplete/uptime ()
(pcomplete-define "uptime" ()
"Completion for the `uptime' command."
(pcomplete-here-using-help "uptime --help"))
;;;###autoload
(defun pcomplete/chcon ()
(pcomplete-define "chcon" ()
"Completion for the `chcon' command."
(pcomplete-here-using-help "chcon --help"))
;;;###autoload
(defun pcomplete/runcon ()
(pcomplete-define "runcon" ()
"Completion for the `runcon' command."
(while (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "runcon --help"))
@ -510,7 +526,7 @@ documentation), this function returns nil."
pcomplete-default-completion-function)))
;;;###autoload
(defun pcomplete/chroot ()
(pcomplete-define "chroot" ()
"Completion for the `chroot' command."
(while (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "chroot --help")))
@ -520,7 +536,7 @@ documentation), this function returns nil."
pcomplete-default-completion-function)))
;;;###autoload
(defun pcomplete/env ()
(pcomplete-define "env" ()
"Completion for the `env' command."
(while (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "env --help"))
@ -531,7 +547,7 @@ documentation), this function returns nil."
pcomplete-default-completion-function)))
;;;###autoload
(defun pcomplete/nice ()
(pcomplete-define "nice" ()
"Completion for the `nice' command."
(while (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "nice --help"))
@ -541,7 +557,7 @@ documentation), this function returns nil."
pcomplete-default-completion-function)))
;;;###autoload
(defun pcomplete/nohup ()
(pcomplete-define "nohup" ()
"Completion for the `nohup' command."
(while (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "nohup --help")))
@ -550,7 +566,7 @@ documentation), this function returns nil."
pcomplete-default-completion-function)))
;;;###autoload
(defun pcomplete/stdbuf ()
(pcomplete-define "stdbuf" ()
"Completion for the `stdbuf' command."
(while (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "stdbuf --help"))
@ -560,7 +576,7 @@ documentation), this function returns nil."
pcomplete-default-completion-function)))
;;;###autoload
(defun pcomplete/timeout ()
(pcomplete-define "timeout" ()
"Completion for the `timeout' command."
(while (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "timeout --help"))
@ -571,12 +587,12 @@ documentation), this function returns nil."
pcomplete-default-completion-function)))
;;;###autoload
(defun pcomplete/numfmt ()
(pcomplete-define "numfmt" ()
"Completion for the `numfmt' command."
(pcomplete-here-using-help "numfmt --help"))
;;;###autoload
(defun pcomplete/seq ()
(pcomplete-define "seq" ()
"Completion for the `seq' command."
(pcomplete-here-using-help "seq --help"))
@ -626,17 +642,19 @@ Uses both `pcmpl-ssh-config-file' and `pcmpl-ssh-known-hosts-file'."
hosts))
;;;###autoload
(defun pcomplete/ssh ()
(pcomplete-define "ssh" ()
"Completion rules for the `ssh' command."
(pcomplete-opt "1246AaCfgKkMNnqsTtVvXxYbcDeFiLlmOopRSw")
(pcomplete-here (pcmpl-ssh-hosts)))
;;;###autoload
(defalias 'pcomplete/rsh #'pcomplete/ssh)
(defalias 'pcomplete/rlogin #'pcomplete/ssh)
(pcomplete-alias "rsh" "ssh")
;;;###autoload
(defun pcomplete/scp ()
(pcomplete-alias "rlogin" "ssh")
;;;###autoload
(pcomplete-define "scp" ()
"Completion rules for the `scp' command.
Includes files as well as host names followed by a colon."
(pcomplete-opt "1246BCpqrvcFiloPS")
@ -664,19 +682,19 @@ Includes files as well as host names followed by a colon."
"Complete a command that wants a hostname for an argument."
(pcomplete-here (pcomplete-read-host-names)))
(defalias 'pcomplete/ftp 'pcmpl-unix-complete-hostname)
(defalias 'pcomplete/ncftp 'pcmpl-unix-complete-hostname)
(defalias 'pcomplete/ping 'pcmpl-unix-complete-hostname)
(pcomplete-define "ftp" () (pcmpl-unix-complete-hostname))
(pcomplete-define "ncftp" () (pcmpl-unix-complete-hostname))
(pcomplete-define "ping" () (pcmpl-unix-complete-hostname))
;;;###autoload
(defun pcomplete/telnet ()
(pcomplete-define "telnet" ()
(pcomplete-opt "xl(pcmpl-unix-user-names)")
(pcmpl-unix-complete-hostname))
;;; Miscellaneous
;;;###autoload
(defun pcomplete/sudo ()
(pcomplete-define "sudo" ()
"Completion for the `sudo' command."
(while (string-prefix-p "-" (pcomplete-arg 0))
(pcomplete-here (pcomplete-from-help "sudo --help"))
@ -686,7 +704,7 @@ Includes files as well as host names followed by a colon."
pcomplete-default-completion-function)))
;;;###autoload
(defun pcomplete/doas ()
(pcomplete-define "doas" ()
"Completion for the `doas' command."
(pcomplete-opt "C(pcomplete-entries)Lnsu(pcmpl-unix-user-names)")
(funcall pcomplete-command-completion-function)

View file

@ -31,19 +31,26 @@
;;; TeX
;;;###autoload
(defun pcomplete/tex ()
(pcomplete-define "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
(pcomplete-alias "pdftex" "tex")
;;;###autoload
(defun pcomplete/luatex ()
(pcomplete-alias "latex" "tex")
;;;###autoload
(pcomplete-alias "pdflatex" "tex")
;;;###autoload
(pcomplete-define "luatex" ()
"Completion for the `luatex' command."
(pcomplete-here-using-help "luatex --help"))
;;;###autoload(defalias 'pcomplete/lualatex 'pcomplete/luatex)
;;;###autoload
(pcomplete-alias "lualatex" "luatex")
;;;; tlmgr - https://www.tug.org/texlive/tlmgr.html
@ -137,7 +144,7 @@
(gethash action pcmpl-x-tlmgr-options-cache)))
;;;###autoload
(defun pcomplete/tlmgr ()
(pcomplete-define "tlmgr" ()
"Completion for the `tlmgr' command."
(while (pcomplete-match "^--" 0)
(pcomplete-here* pcmpl-x-tlmgr-common-options)
@ -161,7 +168,7 @@
;;; Grep-like tools
;;;###autoload
(defun pcomplete/rg ()
(pcomplete-define "rg" ()
"Completion for the `rg' command."
(pcomplete-here-using-help "rg --help"))
@ -245,7 +252,7 @@
(pcmpl-x-ack-long-options "--help-types"))
;;;###autoload
(defun pcomplete/ack ()
(pcomplete-define "ack" ()
"Completion for the `ack' command.
Start an argument with `-' to complete short options and `--' for
long options."
@ -271,7 +278,7 @@ long options."
(pcomplete-here* (pcomplete-dirs-or-entries)))))
;;;###autoload
(defalias 'pcomplete/ack-grep 'pcomplete/ack)
(pcomplete-define "ack-grep" () (pcomplete/ack))
;;;; the_silver_search - https://github.com/ggreer/the_silver_searcher
@ -302,7 +309,7 @@ long options."
(cons 'long (nreverse long)))))))))
;;;###autoload
(defun pcomplete/ag ()
(pcomplete-define "ag" ()
"Completion for the `ag' command."
(while t
(if (pcomplete-match "^-" 0)
@ -313,7 +320,7 @@ long options."
;;; Borland
;;;###autoload
(defun pcomplete/bcc32 ()
(pcomplete-define "bcc32" ()
"Completion function for Borland's C++ compiler."
(let ((cur (pcomplete-arg 0)))
(cond
@ -343,12 +350,12 @@ long options."
(pcomplete-dirs-or-entries "\\.[iCc]\\([Pp][Pp]\\)?\\'"))))
;;;###autoload
(defalias 'pcomplete/bcc 'pcomplete/bcc32)
(pcomplete-define "bcc" () (pcomplete/bcc32))
;;; Network tools
;;;###autoload
(defun pcomplete/rclone ()
(pcomplete-define "rclone" ()
"Completion for the `rclone' command."
(let ((subcmds (pcomplete-from-help "rclone help"
:margin "^ "

View file

@ -41,17 +41,16 @@
;; filenames for the first two arguments, and directories for all
;; remaining arguments:
;;
;; (defun pcomplete/my-command ()
;; (pcomplete-define "my-command" ()
;; (pcomplete-here (pcomplete-entries))
;; (pcomplete-here (pcomplete-entries))
;; (while (pcomplete-here (pcomplete-dirs))))
;;
;; Here are the requirements for completion functions:
;;
;; @ They must be called "pcomplete/MAJOR-MODE/NAME", or
;; "pcomplete/NAME". This is how they are looked up, using the NAME
;; specified in the command argument (the argument in first
;; position).
;; @ They must be defined with `pcomplete-define', using a NAME such
;; as "MAJOR-MODE/COMMAND" or just "COMMAND". This is how they are
;; looked up, using the command name in the first argument position.
;;
;; @ They must be callable with no arguments.
;;
@ -123,6 +122,26 @@
(require 'cl-lib)
(require 'rx))
(defmacro pcomplete-define (name arglist &rest body)
"Define a pcomplete completion function for NAME.
NAME is a string like \"cd\" or \"erc-mode/MSG\".
Registers a lambda in `pcomplete--obarray' for dispatch.
ARGLIST and BODY are as in `defun'."
(declare (indent defun) (autoload-macro expand))
`(progn
(pcomplete--autoload ,name ,load-true-file-name)
:autoload-end
(put (intern ,name pcomplete--obarray) 'pcomplete-function (lambda ,arglist ,@body))))
(defmacro pcomplete-alias (alias name)
"Say that ALIAS should have the same completion function as NAME."
(declare (indent defun) (autoload-macro expand))
`(progn
(pcomplete--autoload ,name ,load-true-file-name)
:autoload-end
(put (intern ,alias pcomplete--obarray) 'pcomplete-function
(get (intern ,name pcomplete--obarray) 'pcomplete-function))))
(defgroup pcomplete nil
"Programmable completion."
:version "21.1"
@ -994,11 +1013,22 @@ component, `default-directory' is used as the basis for completion."
(defun pcomplete-find-completion-function (command)
"Find the completion function to call for the given COMMAND."
(let ((sym (intern-soft
(concat "pcomplete/" (symbol-name major-mode) "/" command))))
(unless sym
(setq sym (intern-soft (concat "pcomplete/" command))))
(and sym (fboundp sym) sym)))
(let* ((sym (or (intern-soft (concat (symbol-name major-mode) "/" command)
pcomplete--obarray)
(intern-soft command pcomplete--obarray)))
(fun (and (get sym 'pcomplete-function))))
;; Lazy-load the file if registered via `pcomplete-attach'.
(when-let* ((file (and sym (null fun) (get sym 'pcomplete-autoload))))
(require (intern file))
(setq fun (get sym 'pcomplete-function)))
(cond (fun)
;; Backward compatibility: fall back to global obarray for packages
;; that still use the old `defun pcomplete/...' naming convention.
((and (setq sym (or (intern-soft
(concat "pcomplete/" (symbol-name major-mode) "/" command))
(intern-soft (concat "pcomplete/" command))))
(fboundp sym))
sym))))
(defun pcomplete-completions ()
"Return a list of completions for the current argument position."

View file

@ -8032,4 +8032,13 @@ and return the value found in PLACE instead."
((pred numberp) v)
(`(,above . ,below) (+ above below)))))
(defvar pcomplete--obarray (obarray-make)
"Special obarry for Pcomplete commands")
(defun pcomplete--autoload (name file)
"Make a note to lazy-load pcomplete command NAME from FILE."
(unless (get (intern name pcomplete--obarray) 'pcomplete-autoload)
(put (intern name pcomplete--obarray) 'pcomplete-autoload file)))
;;; subr.el ends here