branch: master commit c45c5f9e8d176e5a620d4df5740a85830dda6d72 Author: Dmitry Gutov <dgu...@yandex.ru> Commit: Dmitry Gutov <dgu...@yandex.ru>
Extract company-capf--candidates for ease of debugging --- company-capf.el | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/company-capf.el b/company-capf.el index 64b3de9..8a355df 100644 --- a/company-capf.el +++ b/company-capf.el @@ -98,28 +98,7 @@ that accompanied the completion table that's currently is use.") (length (cons prefix length)) (t prefix)))))) (`candidates - (let ((res (company--capf-data))) - (company-capf--save-current-data res) - (when res - (let* ((table (nth 3 res)) - (pred (plist-get (nthcdr 4 res) :predicate)) - (meta (completion-metadata - (buffer-substring (nth 1 res) (nth 2 res)) - table pred)) - (sortfun (cdr (assq 'display-sort-function meta))) - (candidates (completion-all-completions arg table pred (length arg))) - (last (last candidates)) - (base-size (and (numberp (cdr last)) (cdr last)))) - (when base-size - (setcdr last nil)) - (when sortfun - (setq candidates (funcall sortfun candidates))) - (if (not (zerop (or base-size 0))) - (let ((before (substring arg 0 base-size))) - (mapcar (lambda (candidate) - (concat before candidate)) - candidates)) - candidates))))) + (company-capf--candidates arg)) (`sorted (let ((res company-capf--current-completion-data)) (when res @@ -177,6 +156,31 @@ that accompanied the completion table that's currently is use.") (company--capf-post-completion arg)) )) +(defun company-capf--candidates (input) + (let ((res (company--capf-data))) + (company-capf--save-current-data res) + (when res + (let* ((table (nth 3 res)) + (pred (plist-get (nthcdr 4 res) :predicate)) + (meta (completion-metadata + (buffer-substring (nth 1 res) (nth 2 res)) + table pred)) + (sortfun (cdr (assq 'display-sort-function meta))) + (candidates (completion-all-completions input table pred + (length input))) + (last (last candidates)) + (base-size (and (numberp (cdr last)) (cdr last)))) + (when base-size + (setcdr last nil)) + (when sortfun + (setq candidates (funcall sortfun candidates))) + (if (not (zerop (or base-size 0))) + (let ((before (substring input 0 base-size))) + (mapcar (lambda (candidate) + (concat before candidate)) + candidates)) + candidates))))) + (defun company--capf-post-completion (arg) (let* ((res company-capf--current-completion-data) (exit-function (plist-get (nthcdr 4 res) :exit-function))