From 5fb5589d0915112a21475aea3858d7964cff1742 Mon Sep 17 00:00:00 2001 From: 10sr <8.slashes@gmail.com> Date: Tue, 9 Apr 2019 13:36:52 +0900 Subject: [PATCH] Add my-company-length-popup-tip --- emacs.el | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/emacs.el b/emacs.el index fb74c20..d167c36 100644 --- a/emacs.el +++ b/emacs.el @@ -1042,7 +1042,8 @@ found, otherwise returns nil." (set-variable 'company-selection-wrap-around t) (defvar company-mode-map) - ;; TODO: It seems this indent is a bit different from original C-i command + ;; TODO: It seems sometimes this indent is a bit different from original C-i command + ;; For example python-mode? (define-key company-mode-map (kbd "C-i") 'company-indent-or-complete-common) ;; (define-key ctl-x-map (kbd "C-i") 'company-complete) ; Originally `indent-rigidly' @@ -1053,6 +1054,28 @@ found, otherwise returns nil." (define-key company-active-map (kbd "C-i") 'company-complete-selection) (define-key company-active-map (kbd "C-f") 'company-complete-selection) + (defvar company-candidates) + (defvar company-candidates-length) + ;; (popup-tip "Hello, World!") + (require 'popup nil t) + (defun my-company-length-popup-tip () + "Show tooltip of candidate length." + (interactive) + ;; Do nothing when already in company completion + (unless company-candidates + (let ((l nil)) + (unwind-protect + (progn + (company-manual-begin) + (setq l company-candidates-length)) + (company-cancel)) + (when l + (popup-tip (format "(%d)" l)))))) + + (set-variable 'my-company-length-popup-tip-timer + (run-with-idle-timer 0.5 t + 'my-company-length-popup-tip)) + ;; https://qiita.com/syohex/items/8d21d7422f14e9b53b17 (set-face-attribute 'company-tooltip nil :foreground "black" :background "lightgrey") @@ -1071,7 +1094,6 @@ found, otherwise returns nil." ) - ;; https://github.com/lunaryorn/flycheck (when (safe-require-or-eval 'flycheck) (call-after-init (global-flycheck-mode)))