emacs-diffs
[Top][All Lists]
Advanced

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

master 4ff852a5582: ; Optimize 'completion-preview--try-table'


From: Eshel Yaron
Subject: master 4ff852a5582: ; Optimize 'completion-preview--try-table'
Date: Fri, 12 Apr 2024 04:23:11 -0400 (EDT)

branch: master
commit 4ff852a5582be8d0ba16e598371ce359ba3d3cc6
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>

    ; Optimize 'completion-preview--try-table'
    
    * lisp/completion-preview.el (completion-preview-completion-styles):
    New variable.  Default to only include the 'basic' completion style.
    (completion-preview--try-table): Let-bind 'completion-styles' when
    calling 'completion-all-completions'.  With the default value of
    'completion-preview-completion-styles', this yields a significant
    performance improvement (up to 4 times faster compared to the
    'substring' style when tested with 'elisp-completion-at-point').
    
    Suggested by Ergus <spacibba@aol.com>
---
 lisp/completion-preview.el | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/lisp/completion-preview.el b/lisp/completion-preview.el
index 0bdc13bb8a5..4e52aa9b151 100644
--- a/lisp/completion-preview.el
+++ b/lisp/completion-preview.el
@@ -206,6 +206,15 @@ Completion Preview mode adds this function to
                  #'completion-preview--window-selection-change t)
     (completion-preview-hide)))
 
+(defvar completion-preview-completion-styles '(basic)
+  "List of completion styles that Completion Preview mode uses.
+
+Since Completion Preview mode shows prefix completion candidates, this
+list should normally only include completion styles that perform prefix
+completion, but other candidates are filtered out and cause no harm.
+
+See also `completion-styles'.")
+
 (defun completion-preview--try-table (table beg end props)
   "Check TABLE for a completion matching the text between BEG and END.
 
@@ -228,7 +237,11 @@ non-nil, return nil instead."
          (sort-fn (or (completion-metadata-get md 'cycle-sort-function)
                       (completion-metadata-get md 'display-sort-function)
                       completion-preview-sort-function))
-         (all (let ((completion-lazy-hilit t))
+         (all (let ((completion-lazy-hilit t)
+                    ;; FIXME: This does not override styles prescribed
+                    ;; by the completion category via
+                    ;; e.g. `completion-category-defaults'.
+                    (completion-styles completion-preview-completion-styles))
                 (completion-all-completions string table pred
                                             (- (point) beg) md)))
          (last (last all))



reply via email to

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