[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master edbb3c5 16/31: Merge branch 'master' of github.com:company

From: Dmitry Gutov
Subject: [elpa] master edbb3c5 16/31: Merge branch 'master' of github.com:company-mode/company-mode
Date: Sun, 14 Apr 2019 22:06:18 -0400 (EDT)

branch: master
commit edbb3c5354ad7909b4b952c61fd8238fd656b1d0
Merge: 2b671ec a7c689a
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Merge branch 'master' of github.com:company-mode/company-mode
 NEWS.md    |  2 ++
 company.el | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/NEWS.md b/NEWS.md
index 8d252bc..aedac18 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,8 @@
 ## Next
+* Add custom variable `company-show-numbers-function` to make numbers of
+  candidates customizable. 
 * When a symbol is already typed in full, calling `M-x company-complete` will
   now run its post-completion action (e.g. inserting method parameters
   template). Calling `M-x company-manual-begin` or invoking a backend command
diff --git a/company.el b/company.el
index 8b62d51..728c42d 100644
--- a/company.el
+++ b/company.el
@@ -632,6 +632,14 @@ commands in the `company-' namespace, abort completion."
   :type '(choice (const :tag "off" nil)
                  (const :tag "on" t)))
+(defcustom company-show-numbers-function #'company--show-numbers
+  "Function called to get custom quick-access numbers for the first then 
+If nil falls back to default function that generates 1...8, 9, 0. The function 
+the number of candidates (from 1 to 10 means 1st to 10th candidate) and should
+return a string prefixed with one space."
+  :type 'function)
 (defcustom company-selection-wrap-around nil
   "If enabled, selecting item before first or after last wraps around."
   :type '(choice (const :tag "off" nil)
@@ -2635,6 +2643,9 @@ If SHOW-VERSION is non-nil, show the version in the echo 
           (company-safe-substring old (+ offset (length new)))))
+(defun company--show-numbers (numbered)
+  (format " %d" (mod numbered 10)))
 (defsubst company--window-height ()
   (if (fboundp 'window-screen-lines)
       (floor (window-screen-lines))
@@ -2787,7 +2798,7 @@ If SHOW-VERSION is non-nil, show the version in the echo 
           (when (< numbered 10)
             (cl-decf width 2)
             (cl-incf numbered)
-            (setq right (concat (format " %d" (mod numbered 10)) right)))
+            (setq right (concat (funcall company-show-numbers-function 
numbered) right)))
           (push (concat
                  (company-fill-propertize str annotation
                                           width (equal i selection)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]