Skip to content

Instantly share code, notes, and snippets.

@anton0xf
Created July 13, 2021 22:00
Show Gist options
  • Save anton0xf/af75fe3dee6b77c5b28f589856303f4f to your computer and use it in GitHub Desktop.
Save anton0xf/af75fe3dee6b77c5b28f589856303f4f to your computer and use it in GitHub Desktop.
(defun company--begin-new ()
(let (prefix c)
(cl-dolist (backend (if company-backend
;; prefer manual override
(list company-backend)
company-backends))
(setq prefix
(if (or (symbolp backend)
(functionp backend))
(when (company--maybe-init-backend backend)
(let ((company-backend backend))
(company-call-backend 'prefix)))
(company--multi-backend-adapter backend 'prefix)))
(when prefix
(when (company--good-prefix-p prefix)
(let ((ignore-case (company-call-backend 'ignore-case)))
(setq company-prefix (company--prefix-str prefix)
company-backend backend
c (company-calculate-candidates company-prefix ignore-case))
(message ">> backend: %s, candidates: %S" backend c) ;; <--- show candidates
(cond
((and company-abort-on-unique-match
(company--unique-match-p c company-prefix ignore-case)
(if company--manual-action
;; If `company-manual-begin' was called, the user
;; really wants something to happen. Otherwise...
(ignore (message "Sole completion"))
t))
;; ...abort and run the hooks, e.g. to clear the cache.
(company-cancel 'unique))
((null c)
(when company--manual-action
(message "No completion found")))
(t ;; We got completions!
(when company--manual-action
(setq company--manual-prefix prefix))
(company-update-candidates c)
(run-hook-with-args 'company-completion-started-hook
(company-explicit-action-p))
(company-call-frontends 'show)))))
(cl-return c)))))
@anton0xf
Copy link
Author

Changed version of company-mode/company--begin-new function for cpitclaudel/company-coq#252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment