Function: completion-table-with-context
completion-table-with-context is a byte-compiled function defined in
minibuffer.el.gz.
Signature
(completion-table-with-context PREFIX TABLE STRING PRED ACTION)
Source Code
;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun completion-table-with-context (prefix table string pred action)
;; TODO: add `suffix' maybe?
(let ((pred
(if (not (functionp pred))
;; Notice that `pred' may not be a function in some abusive cases.
pred
;; Predicates are called differently depending on the nature of
;; the completion table :-(
(cond
((obarrayp table)
(lambda (sym) (funcall pred (concat prefix (symbol-name sym)))))
((hash-table-p table)
(lambda (s _v) (funcall pred (concat prefix s))))
((functionp table)
(lambda (s) (funcall pred (concat prefix s))))
(t ;Lists and alists.
(lambda (s)
(funcall pred (concat prefix (if (consp s) (car s) s)))))))))
(if (eq (car-safe action) 'boundaries)
(let* ((len (length prefix))
(bound (completion-boundaries string table pred (cdr action))))
`(boundaries ,(+ (car bound) len) . ,(cdr bound)))
(let ((comp (complete-with-action action table string pred)))
(cond
;; In case of try-completion, add the prefix.
((stringp comp) (concat prefix comp))
(t comp))))))