From: Dmitry Gutov Date: Fri, 20 Feb 2015 22:32:33 +0000 (+0200) Subject: Add `company-diag' X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/e6ea77958ac7050a9bbc43bff54a77365924ad24 Add `company-diag' --- diff --git a/NEWS.md b/NEWS.md index c7a1afe53..c8dd158eb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # History of user-visible changes +## Next + +* New command `company-diag`. Use it in bug reports. + ## 2015-02-02 (0.8.10) * New variable `company-lighter-base`. diff --git a/company.el b/company.el index 99c7eb5ec..5461fa6b8 100644 --- a/company.el +++ b/company.el @@ -2131,6 +2131,39 @@ If SHOW-VERSION is non-nil, show the version in the echo area." (message "Company version: %s" (lm-version)) (lm-version)))) +(defun company-diag () + (interactive) + "Pop a buffer with information about completions at point." + (let* ((bb company-backends) + backend + (prefix (cl-loop for b in bb + thereis (let ((company-backend b)) + (setq backend b) + (company-call-backend 'prefix)))) + cc) + (when (stringp prefix) + (setq cc (let ((company-backend backend)) + (company-call-backend 'candidates prefix)))) + (pop-to-buffer (get-buffer-create "*company-diag*")) + (setq buffer-read-only nil) + (erase-buffer) + (insert "company-backends: " (pp-to-string bb)) + (insert "\n") + (insert "Used backend: " (pp-to-string backend)) + (insert "\n") + (insert "Prefix: " (pp-to-string prefix)) + (insert "\n") + (insert (message "Completions:")) + (unless cc (insert " none")) + (save-excursion + (let ((company-backend backend)) + (dolist (c cc) + (insert "\n " (prin1-to-string c)) + (let ((ann (company-call-backend 'annotation))) + (when ann + (insert " " (prin1-to-string ann)))))) + (special-mode)))) + ;;; pseudo-tooltip ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar-local company-pseudo-tooltip-overlay nil)