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

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

[elpa] master 5e49ddf 08/29: Take the exact candidate as an nonoptional


From: Dmitry Gutov
Subject: [elpa] master 5e49ddf 08/29: Take the exact candidate as an nonoptional arg
Date: Tue, 28 Mar 2017 20:50:34 -0400 (EDT)

branch: master
commit 5e49ddf3d2fe8baf1eff12383df2c6dc5ead9ef7
Author: Kiso Katsuyuki <address@hidden>
Commit: Kiso Katsuyuki <address@hidden>

    Take the exact candidate as an nonoptional arg
    
    By this change `company-preview-show-at-point`
    takes the exact completion candidate
    as an nonoptional arg. So the candidate was added as
    the arg where this function is called.
    
    At the previous change `company-preview-frontend` was modified to
    take the new argument, but it was returned at this time.
    Made `company-preview-common-frontend` not to call
    `company-preview-frontend`, and instead it called
    `company-preview-show-at-point` directly.
---
 company.el | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/company.el b/company.el
index d8b3077..d219b7d 100644
--- a/company.el
+++ b/company.el
@@ -2916,14 +2916,13 @@ Delay is determined by `company-tooltip-idle-delay'."
 
 (defvar-local company-preview-overlay nil)
 
-(defun company-preview-show-at-point (pos &optional company-common)
+(defun company-preview-show-at-point (pos completion)
   (company-preview-hide)
 
-  (let ((completion  (or company-common (nth company-selection 
company-candidates))))
-    (setq completion (copy-sequence (company--pre-render completion)))
-    (font-lock-append-text-property 0 (length completion)
-                                    'face 'company-preview
-                                    completion)
+  (setq completion (copy-sequence (company--pre-render completion)))
+  (font-lock-append-text-property 0 (length completion)
+                                  'face 'company-preview
+                                  completion)
     (font-lock-prepend-text-property 0 (length company-common)
                                      'face 'company-preview-common
                                      completion)
@@ -2960,18 +2959,19 @@ Delay is determined by `company-tooltip-idle-delay'."
       (let ((ov company-preview-overlay))
         (overlay-put ov (if ptf-workaround 'display 'after-string)
                      completion)
-        (overlay-put ov 'window (selected-window))))))
+        (overlay-put ov 'window (selected-window)))))
 
 (defun company-preview-hide ()
   (when company-preview-overlay
     (delete-overlay company-preview-overlay)
     (setq company-preview-overlay nil)))
 
-(defun company-preview-frontend (command &optional company-common)
+(defun company-preview-frontend (command)
   "`company-mode' frontend showing the selection as if it had been inserted."
   (pcase command
     (`pre-command (company-preview-hide))
-    (`post-command (company-preview-show-at-point (point) company-common))
+    (`post-command (company-preview-show-at-point (point)
+                                                  (nth company-selection 
company-candidates)))
     (`hide (company-preview-hide))))
 
 (defun company-preview-if-just-one-frontend (command)
@@ -2992,15 +2992,19 @@ Delay is determined by `company-tooltip-idle-delay'."
     (not (overlay-get company-pseudo-tooltip-overlay 'invisible))))
 
 (defun company-preview-common--show-p ()
+  "Returns whether the preview of common can be showed or not"
   (and company-common
        (or (eq (company-call-backend 'ignore-case) 'keep-prefix)
            (string-prefix-p company-prefix company-common))))
 
 (defun company-preview-common-frontend (command)
-  "`company-preview-frontend', but only shown for single candidates."
+  "`company-mode' frontend preview the common part of candidates."
   (when (or (not (eq command 'post-command))
             (company-preview-common--show-p))
-    (company-preview-frontend command company-common)))
+    (pcase command
+      (`pre-command (company-preview-hide))
+      (`post-command (company-preview-show-at-point (point) company-common))
+      (`hide (company-preview-hide)))))
 
 ;;; echo 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 



reply via email to

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