]> rtime.felk.cvut.cz Git - sojka/company-mode.git/commitdiff
Added echo front-end.
authorNikolaj Schumacher <git@nschum.de>
Wed, 11 Mar 2009 11:59:19 +0000 (12:59 +0100)
committerNikolaj Schumacher <git@nschum.de>
Thu, 19 Mar 2009 19:55:52 +0000 (20:55 +0100)
company.el

index c3842ac2d943d741cbee103ad05eefa9995d823c..cd7237a4f167576abd791eab7615ca4fed397b5d 100644 (file)
   "*"
   :group 'company)
 
+(defface company-echo nil
+  "*"
+  :group 'company)
+
+(defface company-echo-common
+  '((((background dark)) (:foreground "firebrick1"))
+    (((background light)) (:background "firebrick4")))
+  "*"
+  :group 'company)
+
 (defcustom company-backends '(company-elisp-completion)
   "*"
   :group 'company
         company-selection 0
         company-selection-changed nil
         company-point nil)
-  (company-pseudo-tooltip-hide))
+  (company-pseudo-tooltip-hide)
+  (company-echo-hide))
 
 (defun company-pre-command ()
   (company-preview-hide)
-  (company-pseudo-tooltip-hide))
+  (company-pseudo-tooltip-hide)
+  (company-echo-refresh))
 
 (defun company-post-command ()
   (unless (equal (point) company-point)
     (company-begin))
   (when company-candidates
+    (company-echo-show company-candidates))
     (company-pseudo-tooltip-show-at-point (- (point) (length company-prefix))
                                           company-candidates
                                           company-selection)
     (company-preview-show-at-point (point) company-candidates
-                                   company-selection)))
+                                   company-selection))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
     (delete-overlay company-preview-overlay)
     (setq company-preview-overlay nil)))
 
+;;; echo ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(defvar company-echo-last-msg nil)
+(make-variable-buffer-local 'company-echo-last-msg)
+
+(defun company-echo-refresh ()
+  (let ((message-log-max nil))
+    (if company-echo-last-msg
+        (message "%s" company-echo-last-msg)
+      (message ""))))
+
+(defun company-echo-show (candidates)
+
+  ;; Roll to selection.
+  (setq candidates (nthcdr company-selection candidates))
+
+  (let ((limit (window-width (minibuffer-window)))
+        (len 0)
+        comp msg)
+    (while candidates
+      (setq comp (pop candidates)
+            len (+ len 1 (length comp)))
+      (if (>= len limit)
+          (setq candidates nil)
+        (setq comp (propertize comp 'face 'company-echo))
+        (add-text-properties 0 (length company-common)
+                             '(face company-echo-common) comp)
+        (push comp msg)))
+
+    (setq company-echo-last-msg (mapconcat 'identity (nreverse msg) " "))
+    (company-echo-refresh)))
+
+(defun company-echo-hide ()
+  (setq company-echo-last-msg nil))
+
 (provide 'company)
 ;;; company.el ends here