]> git.eshelyaron.com Git - sweep.git/commitdiff
* (sweeprolog-predicate-completion-at-point): use holes for args
authorEshel Yaron <me@eshelyaron.com>
Sat, 19 Nov 2022 19:21:20 +0000 (21:21 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sat, 19 Nov 2022 19:21:20 +0000 (21:21 +0200)
sweep.pl
sweeprolog.el

index 7645e55b1c9340ba19ce10ea0e991e4b31c66c4e..84f6dbc9b0ffc79f5e13b0cc26d791cc10dbbed8 100644 (file)
--- 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|_],
index 92cc38d8e4adf1f4425b9cdfebc5560f65c0ad2c..8e116e81f585f0349078a81db13cda87de00634d 100644 (file)
@@ -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