]> code.delx.au - gnu-emacs-elpa/commitdiff
Indicate current candidate's backend when it's in a group
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 15 Jun 2014 04:03:52 +0000 (07:03 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 15 Jun 2014 04:04:24 +0000 (07:04 +0300)
Closes #109

NEWS.md
company.el

diff --git a/NEWS.md b/NEWS.md
index ac0361f95681fd32096bc5a938d6eed7d07031b6..4c2ffe15ccc8b52ebb154d5324686a4ee08c1c18 100644 (file)
--- 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`.
index c8101004cec798c6874ff096f93bc0d73dd7c9ab..b61bda6dc6fe20becb7fa7c10b8262d964713767 100644 (file)
@@ -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))