From: Dmitry Gutov Date: Tue, 30 Mar 2021 00:42:11 +0000 (+0300) Subject: Provide information to show icons with Elisp completions X-Git-Tag: emacs-28.0.90~3087 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=24c92b35b5ed8432e53a27ed3cb477788894ecdc;p=emacs.git Provide information to show icons with Elisp completions * lisp/progmodes/elisp-mode.el (elisp--company-kind): New function. (elisp-completion-at-point): Use it. And a couple of anonymous :company-kind functions too. --- diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el index cdf60859d06..8ade718640c 100644 --- a/lisp/progmodes/elisp-mode.el +++ b/lisp/progmodes/elisp-mode.el @@ -530,6 +530,7 @@ functions are annotated with \"\" via the ((elisp--expect-function-p beg) (list nil obarray :predicate #'fboundp + :company-kind #'elisp--company-kind :company-doc-buffer #'elisp--company-doc-buffer :company-docsig #'elisp--company-doc-string :company-location #'elisp--company-location)) @@ -543,6 +544,7 @@ functions are annotated with \"\" via the (symbol-plist sym))) :annotation-function (lambda (str) (if (fboundp (intern-soft str)) " ")) + :company-kind #'elisp--company-kind :company-doc-buffer #'elisp--company-doc-buffer :company-docsig #'elisp--company-doc-string :company-location #'elisp--company-location)) @@ -553,6 +555,11 @@ functions are annotated with \"\" via the obarray #'boundp 'strict)) + :company-kind + (lambda (s) + (if (test-completion s elisp--local-variables-completion-table) + 'value + 'variable)) :company-doc-buffer #'elisp--company-doc-buffer :company-docsig #'elisp--company-doc-string :company-location #'elisp--company-location))) @@ -599,11 +606,13 @@ functions are annotated with \"\" via the (looking-at "\\_")))) (list t obarray :predicate #'boundp + :company-kind (lambda (_) 'variable) :company-doc-buffer #'elisp--company-doc-buffer :company-docsig #'elisp--company-doc-string :company-location #'elisp--company-location)) (_ (list nil obarray :predicate #'fboundp + :company-kind #'elisp--company-kind :company-doc-buffer #'elisp--company-doc-buffer :company-docsig #'elisp--company-doc-string :company-location #'elisp--company-location @@ -619,6 +628,16 @@ functions are annotated with \"\" via the " " (cadr table-etc))) (cddr table-etc))))))))) +(defun elisp--company-kind (str) + (let ((sym (intern-soft str))) + (cond + ((or (macrop sym) (special-form-p sym)) 'keyword) + ((fboundp sym) 'function) + ((boundp sym) 'variable) + ((featurep sym) 'module) + ((facep sym) 'color) + (t 'text)))) + (defun lisp-completion-at-point (&optional _predicate) (declare (obsolete elisp-completion-at-point "25.1")) (elisp-completion-at-point))