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

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

[nongnu] elpa/cider 176a8e7485: [completion] Cache last result of `cider


From: ELPA Syncer
Subject: [nongnu] elpa/cider 176a8e7485: [completion] Cache last result of `cider-complete`
Date: Fri, 10 May 2024 12:59:49 -0400 (EDT)

branch: elpa/cider
commit 176a8e748540705b9229870be1ebe8a77f756966
Author: Oleksandr Yakushev <alex@bytopia.org>
Commit: Oleksandr Yakushev <alex@bytopia.org>

    [completion] Cache last result of `cider-complete`
---
 cider-completion.el | 48 ++++++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/cider-completion.el b/cider-completion.el
index 9f83e47152..6b54420c73 100644
--- a/cider-completion.el
+++ b/cider-completion.el
@@ -184,26 +184,34 @@ performed by `cider-annotate-completion-function'."
   (when-let* ((bounds (bounds-of-thing-at-point 'symbol)))
     (when (and (cider-connected-p)
                (not (or (cider-in-string-p) (cider-in-comment-p))))
-      (list (car bounds) (cdr bounds)
-            (lambda (prefix pred action)
-              ;; When the 'action is 'metadata, this lambda returns metadata 
about this
-              ;; capf, when action is (boundaries . suffix), it returns nil. 
With every
-              ;; other value of 'action (t, nil, or lambda), 'action is 
forwarded to
-              ;; (complete-with-action), together with (cider-complete), 
prefix and pred.
-              ;; And that function performs the completion based on those 
arguments.
-              ;;
-              ;; This api is better described in the section
-              ;; '21.6.7 Programmed Completion' of the elisp manual.
-              (cond ((eq action 'metadata) `(metadata (category . cider))) ;; 
defines a completion category named 'cider, used later in our 
`completion-category-overrides` logic.
-                    ((eq (car-safe action) 'boundaries) nil)
-                    (t (with-current-buffer (current-buffer)
-                         (complete-with-action action
-                                               (cider-complete prefix) prefix 
pred)))))
-            :annotation-function #'cider-annotate-symbol
-            :company-kind #'cider-company-symbol-kind
-            :company-doc-buffer #'cider-create-compact-doc-buffer
-            :company-location #'cider-company-location
-            :company-docsig #'cider-company-docsig))))
+      (let* (last-prefix
+             last-result
+             (complete
+              (lambda (prefix)
+                (unless (string-equal last-prefix prefix)
+                  (setq last-prefix prefix)
+                  (setq last-result (cider-complete prefix)))
+                last-result)))
+        (list (car bounds) (cdr bounds)
+              (lambda (prefix pred action)
+                ;; When the 'action is 'metadata, this lambda returns metadata 
about this
+                ;; capf, when action is (boundaries . suffix), it returns nil. 
With every
+                ;; other value of 'action (t, nil, or lambda), 'action is 
forwarded to
+                ;; (complete-with-action), together with (cider-complete), 
prefix and pred.
+                ;; And that function performs the completion based on those 
arguments.
+                ;;
+                ;; This api is better described in the section
+                ;; '21.6.7 Programmed Completion' of the elisp manual.
+                (cond ((eq action 'metadata) `(metadata (category . cider))) 
;; defines a completion category named 'cider, used later in our 
`completion-category-overrides` logic.
+                      ((eq (car-safe action) 'boundaries) nil)
+                      (t (with-current-buffer (current-buffer)
+                           (complete-with-action action
+                                                 (funcall complete prefix) 
prefix pred)))))
+              :annotation-function #'cider-annotate-symbol
+              :company-kind #'cider-company-symbol-kind
+              :company-doc-buffer #'cider-create-compact-doc-buffer
+              :company-location #'cider-company-location
+              :company-docsig #'cider-company-docsig)))))
 
 (defun cider-completion-flush-caches ()
   "Force Compliment to refill its caches.



reply via email to

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