From 1683c9a6c81c0f85a04a26c7259be74192d2f4de Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Sat, 19 Nov 2022 21:21:20 +0200 Subject: [PATCH] * (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 7645e55..84f6dbc 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 92cc38d..8e116e8 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 -- 2.39.2