]> git.eshelyaron.com Git - dict.git/commitdiff
ENHANCED: faster completion-at-point for predicates
authorEshel Yaron <me@eshelyaron.com>
Sat, 20 May 2023 14:52:17 +0000 (17:52 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sat, 20 May 2023 14:52:17 +0000 (17:52 +0300)
Filter predicate completion candidates according to the text near
point before formatting and computing argument names.  This makes
completion-at-point for predicates much faster when there are lots of
known predicates.

* sweeprolog.el (sweeprolog-predicate-completion-at-point): Pass
(partial) functor at point to...
* sweep.pl (sweep_predicate_completion_candidates/2): Filter
predicates based on new Sub argument.

sweep.pl
sweeprolog.el

index 71c63feefad855ac01e00450030f2d3b395f58c0..154b50ab1da02a815e7442972a6f7a41f697ec9e 100644 (file)
--- a/sweep.pl
+++ b/sweep.pl
@@ -865,18 +865,19 @@ sweep_atom_collection(Sub, Col) :-
     findall(S,
             (   current_atom(A),
                 atom_string(A, S),
-                sub_string(S, _, _, _, Sub)
+                once(sub_string(S, _, _, _, Sub))
             ),
             Col).
 
-sweep_predicate_completion_candidates(D, Ps) :-
+sweep_predicate_completion_candidates([D|Sub], Ps) :-
     integer(D),
     sweep_current_module(M),
     findall(H,
             (   (   @(predicate_property(H, visible), M)
                 ;   xref_defined(_, H, _)
                 ),
-                pi_head(_/N, H),
+                pi_head(F/N, H),
+                once(sub_atom(F, _, _, _, Sub)),
                 N - D >= 0
             ),
             Hs),
index 190024112dc26a7ef4339acfdefe3147e7ced04e..e0faa1418dd2c2171bdf36b13b67726c9d927566 100644 (file)
@@ -1240,8 +1240,10 @@ resulting list even when found in the current clause."
                  (not (or (sweeprolog--char-uppercase-p first)
                           (= first ?_)))))
       (when-let
-          ((col (sweeprolog--query-once "sweep" "sweep_predicate_completion_candidates"
-                                        (sweeprolog-context-callable-p))))
+          ((col (sweeprolog--query-once
+                 "sweep" "sweep_predicate_completion_candidates"
+                 (cons (sweeprolog-context-callable-p)
+                       (buffer-substring-no-properties beg end)))))
         (list beg end col
               :exclusive 'no
               :annotation-function