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

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

[elpa] externals/company 0c2a8e5 2/3: Merge pull request #1118 from yuga


From: ELPA Syncer
Subject: [elpa] externals/company 0c2a8e5 2/3: Merge pull request #1118 from yugaego/complete-nth
Date: Fri, 18 Jun 2021 16:57:07 -0400 (EDT)

branch: externals/company
commit 0c2a8e5f8d27c700369500e72afd533b88ecff3b
Merge: 36839ec 32386cc
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: GitHub <noreply@github.com>

    Merge pull request #1118 from yugaego/complete-nth
    
    Rename and document company-complete-number
---
 NEWS.md    |  3 +++
 company.el | 48 +++++++++++++++++++++++++++++++-----------------
 2 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/NEWS.md b/NEWS.md
index 35408b2..e5e6bdc 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,9 @@
 
 ## Next
 
+* `company-complete-number` declared obsolete in favor of
+   `company-complete-tooltip-row`
+  ([#1118](https://github.com/company-mode/company-mode/pull/1118)).
 * New faces `company-tooltip-quick-access` and
   `company-tooltip-quick-access-selection`
   ([#303](https://github.com/company-mode/company-mode/issues/303)).
diff --git a/company.el b/company.el
index 9bda6b0..f6aabd1 100644
--- a/company.el
+++ b/company.el
@@ -720,7 +720,7 @@ asynchronous call into synchronous.")
     (define-key keymap "\C-s" 'company-search-candidates)
     (define-key keymap "\C-\M-s" 'company-filter-candidates)
     (dotimes (i 10)
-      (define-key keymap (read-kbd-macro (format "M-%d" i)) 
'company-complete-number))
+      (define-key keymap (read-kbd-macro (format "M-%d" i)) 
'company-complete-tooltip-row))
      keymap)
   "Keymap that is enabled during an active completion.")
 
@@ -2067,7 +2067,7 @@ prefix match (same case) will be prioritized."
                                           company-complete
                                           company-complete-common
                                           company-complete-selection
-                                          company-complete-number)
+                                          company-complete-tooltip-row)
   "List of commands after which idle completion is (still) disabled when
 `company-begin-commands' is t.")
 
@@ -2286,7 +2286,7 @@ each one wraps a part of the input string."
     (define-key keymap "\C-r" 'company-search-repeat-backward)
     (define-key keymap "\C-o" 'company-search-toggle-filtering)
     (dotimes (i 10)
-      (define-key keymap (read-kbd-macro (format "M-%d" i)) 
'company-complete-number))
+      (define-key keymap (read-kbd-macro (format "M-%d" i)) 
'company-complete-tooltip-row))
     keymap)
   "Keymap used for incrementally searching the completion candidates.")
 
@@ -2534,11 +2534,22 @@ inserted."
       (when company-candidates
         (setq this-command 'company-complete-common)))))
 
-(defun company-complete-number (n)
-  "Insert the Nth candidate visible in the tooltip.
-To show the number next to the candidates in some backends, enable
-`company-show-numbers'.  When called interactively, uses the last typed
-character, stripping the modifiers.  That character must be a digit."
+(define-obsolete-function-alias
+  'company-complete-number
+  'company-complete-tooltip-row
+  "0.9.14")
+
+(defun company-complete-tooltip-row (number)
+  "Insert a candidate visible on the tooltip's row NUMBER.
+
+Inserts one of the first ten candidates,
+numerated according to the current scrolling position.
+NUMBER 1 inserts a candidate visible on the first row.
+NUMBER 0 inserts a candidate visible on the tenth row of the tooltip.
+
+When called interactively, uses the last typed digit, stripping the modifiers.
+
+To show hint numbers beside the candidates, enable `company-show-numbers'."
   (interactive
    (list (let* ((type (event-basic-type last-command-event))
                 (char (if (characterp type)
@@ -2546,15 +2557,18 @@ character, stripping the modifiers.  That character 
must be a digit."
                           type
                         ;; Keypad number, if bound directly.
                         (car (last (string-to-list (symbol-name type))))))
-                (n (- char ?0)))
-           (if (zerop n) 10 n))))
-  (when (company-manual-begin)
-    (and (or (< n 1) (> n (- company-candidates-length
-                             company-tooltip-offset)))
-         (user-error "No candidate number %d" n))
-    (cl-decf n)
-    (company-finish (nth (+ n company-tooltip-offset)
-                         company-candidates))))
+                (number (- char ?0)))
+           (if (zerop number) 10 number))))
+  (company--complete-nth (1- number)))
+
+(defun company--complete-nth (row)
+   "Insert a candidate visible on the tooltip's zero-based ROW."
+   (when (company-manual-begin)
+     (and (or (< row 0) (>= row (- company-candidates-length
+                                   company-tooltip-offset)))
+          (user-error "No candidate on the row number %d" row))
+     (company-finish (nth (+ row company-tooltip-offset)
+                          company-candidates))))
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 



reply via email to

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