emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] master a7c689a 14/31: Merge pull request #859 from yqrashawn/cust


From: Dmitry Gutov
Subject: [elpa] master a7c689a 14/31: Merge pull request #859 from yqrashawn/customizable-numbers
Date: Sun, 14 Apr 2019 22:06:17 -0400 (EDT)

branch: master
commit a7c689a9ef5d07ae88beb95f09f1bbe06d2f1f27
Merge: f53327b 66ed6df
Author: Dmitry Gutov <address@hidden>
Commit: GitHub <address@hidden>

    Merge pull request #859 from yqrashawn/customizable-numbers
    
    make numbers after candidates customizable
---
 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 3c13b7b..6f8feb8 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 
candidates.
+
+If nil falls back to default function that generates 1...8, 9, 0. The function 
get
+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 
area."
           new
           (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 
area."
           (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]