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

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

[nongnu] elpa/sweeprolog 1683c9a6c8 3/8: * (sweeprolog-predicate-complet


From: ELPA Syncer
Subject: [nongnu] elpa/sweeprolog 1683c9a6c8 3/8: * (sweeprolog-predicate-completion-at-point): use holes for args
Date: Sat, 19 Nov 2022 15:59:26 -0500 (EST)

branch: elpa/sweeprolog
commit 1683c9a6c81c0f85a04a26c7259be74192d2f4de
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>

    * (sweeprolog-predicate-completion-at-point): use holes for args
---
 sweep.pl      |  5 +++--
 sweeprolog.el | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/sweep.pl b/sweep.pl
index 7645e55b1c..84f6dbc9b0 100644
--- a/sweep.pl
+++ b/sweep.pl
@@ -761,13 +761,14 @@ sweep_predicate_completion_candidates(_, Ps) :-
             Hs),
     maplist(sweep_format_predicate, Hs, Ps).
 
-sweep_format_predicate(H, S) :-
+sweep_format_predicate(H, [S|SP]) :-
     term_variables(H, Vs),
     maplist(=('$VAR'('_')), Vs),
     term_string(H, S, [quoted(true),
                        character_escapes(true),
                        spacing(next_argument),
-                       numbervars(true)]).
+                       numbervars(true)]),
+    term_string(_, S, [subterm_positions(SP)]).
 
 sweep_context_callable([H|T], R) :-
     H = [F0|_],
diff --git a/sweeprolog.el b/sweeprolog.el
index 92cc38d8e4..8e116e81f5 100644
--- a/sweeprolog.el
+++ b/sweeprolog.el
@@ -1059,7 +1059,25 @@ resulting list even when found in the current clause."
         (list beg end col
               :exclusive 'no
               :annotation-function
-              (lambda (_) " Predicate"))))))
+              (lambda (_) " Predicate")
+              :exit-function
+              (lambda (string status)
+                (pcase status
+                  ('finished (pcase (cdr (assoc-string string col))
+                               (`(compound
+                                  "term_position"
+                                  0 ,length
+                                  fbeg fend
+                                  ,holes)
+                                (with-silent-modifications
+                                  (dolist (hole holes)
+                                    (pcase hole
+                                      (`(compound "-" ,hbeg ,hend)
+                                       (put-text-property (- (point) length (- 
hbeg))
+                                                          (- (point) length (- 
hend))
+                                                          'sweeprolog-hole 
t)))))
+                                (backward-char length)
+                                (sweeprolog-forward-hole)))))))))))
 
 
 ;;;; Packages



reply via email to

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