This page is about standard Emacs library `pcomplete.el’ and its related libraries. See PcompleteExamples for examples of using `pcomplete.el’.

Note: The “programmable completion” of library `pcomplete.el’ has nothing to do with the “programmed completion” described in the EmacsLisp manual (dynamic-completion-table). The latter is about using a function to perform completion rather than supplying an explicit list of completion candidates.

Adding programmable completion using pcomplete


(defun pcomplete-erc-setup () 
"Setup erc-mode to use pcomplete." 
(set (make-local-variable 'pcomplete-parse-arguments-function) 
(set (make-local-variable 'pcomplete-command-completion-function)  
(set (make-local-variable 'pcomplete-command-name-function) 
(set (make-local-variable 'pcomplete-default-completion-function)
    (lambda () (pcomplete-here (pcomplete-erc-nicks))))
(set (make-local-variable 'pcomplete-suffix-list) '(?  ?:)) 
(add-hook 'erc-mode-hook 'pcomplete-erc-setup)                                                                                                                                                         

pcomplete-parse-arguments-function has no parameters. It returns a list of arguments for the current command.

Returns the canonical name of the command. This is used to find the appropriate programmable completion function. For example, if the function returns “MSG” and the major mode is “erc-mode”, pcomplete will check pcomplete/erc-mode/MSG and pcomplete/MSG for completions.

pcomplete-default-completion-function gets called when you don’t have a function for the command currently being completed. Body should be of the form (pcomplete-here (… list of completions …))

Body should be of the form (pcomplete-here (… list of completions …))

CategoryCode CategoryCompletion