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

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

[elpa] master 65fd368 09/40: Support completion style specific sorting (


From: Dmitry Gutov
Subject: [elpa] master 65fd368 09/40: Support completion style specific sorting (Emacs 27)
Date: Thu, 2 Jan 2020 18:57:00 -0500 (EST)

branch: master
commit 65fd3685e627b9b45535c6251e633795c4cbd43d
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Support completion style specific sorting (Emacs 27)
---
 company-capf.el | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/company-capf.el b/company-capf.el
index 8a355df..e8b425b 100644
--- a/company-capf.el
+++ b/company-capf.el
@@ -83,6 +83,8 @@ that accompanied the completion table that's currently is 
use.")
 (defun company-capf--clear-current-data (_ignored)
   (setq company-capf--current-completion-data nil))
 
+(defvar-local company-capf--sorted nil)
+
 (defun company-capf (command &optional arg &rest _args)
   "`company-mode' backend using `completion-at-point-functions'."
   (interactive (list 'interactive))
@@ -100,12 +102,7 @@ that accompanied the completion table that's currently is 
use.")
     (`candidates
      (company-capf--candidates arg))
     (`sorted
-     (let ((res company-capf--current-completion-data))
-       (when res
-         (let ((meta (completion-metadata
-                      (buffer-substring (nth 1 res) (nth 2 res))
-                      (nth 3 res) (plist-get (nthcdr 4 res) :predicate))))
-           (cdr (assq 'display-sort-function meta))))))
+     company-capf--sorted)
     (`match
      ;; Ask the for the `:company-match' function.  If that doesn't help,
      ;; fallback to sniffing for face changes to get a suitable value.
@@ -165,13 +162,15 @@ that accompanied the completion table that's currently is 
use.")
              (meta (completion-metadata
                     (buffer-substring (nth 1 res) (nth 2 res))
                     table pred))
-             (sortfun (cdr (assq 'display-sort-function meta)))
              (candidates (completion-all-completions input table pred
-                                                     (length input)))
+                                                     (length input)
+                                                     meta))
+             (sortfun (cdr (assq 'display-sort-function meta)))
              (last (last candidates))
              (base-size (and (numberp (cdr last)) (cdr last))))
         (when base-size
           (setcdr last nil))
+        (setq company-capf--sorted (functionp sortfun))
         (when sortfun
           (setq candidates (funcall sortfun candidates)))
         (if (not (zerop (or base-size 0)))



reply via email to

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