From: Dmitry Gutov Date: Sun, 15 Jun 2014 04:03:52 +0000 (+0300) Subject: Indicate current candidate's backend when it's in a group X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/8783c6ffacdf85bf921b8fb013de5839e3f47d16 Indicate current candidate's backend when it's in a group Closes #109 --- diff --git a/NEWS.md b/NEWS.md index ac0361f95..4c2ffe15c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ ## Next +* When grouped back-ends are used, the back-end of the current candidate is + indicated in the mode-line, enclosed in angle brackets. * New user option `company-gtags-insert-arguments`, t by default. * `company-css` knows about CSS3. * `company-gtags` supports `meta` and `annotation`. diff --git a/company.el b/company.el index c8101004c..b61bda6dc 100644 --- a/company.el +++ b/company.el @@ -1037,10 +1037,20 @@ can retrieve meta-data for them." (mod selection company-candidates-length) (max 0 (min (1- company-candidates-length) selection)))) (when (or force-update (not (equal selection company-selection))) + (company-update-group-lighter (nth selection company-candidates)) (setq company-selection selection company-selection-changed t) (company-call-frontends 'update))) +(defun company-update-group-lighter (candidate) + (when (listp company-backend) + (let ((backend (or (get-text-property 0 'company-backend candidate) + (car company-backend)))) + (when (and backend (symbolp backend)) + (let ((name (replace-regexp-in-string "company-\\|-company" "" + (symbol-name backend)))) + (setq company-lighter (format " company-<%s>" name))))))) + (defun company-apply-predicate (candidates predicate) (let (new) (dolist (c candidates) @@ -1375,8 +1385,9 @@ Keywords and function definition names are ignored." (message "No completion found")) (when company--manual-action (setq company--manual-prefix prefix)) - (when (symbolp backend) - (setq company-lighter (concat " " (symbol-name backend)))) + (if (symbolp backend) + (setq company-lighter (concat " " (symbol-name backend))) + (company-update-group-lighter (car c))) (company-update-candidates c) (run-hook-with-args 'company-completion-started-hook (company-explicit-action-p))