From: Eshel Yaron Date: Sat, 19 Nov 2022 19:21:20 +0000 (+0200) Subject: * (sweeprolog-predicate-completion-at-point): use holes for args X-Git-Tag: V8.5.20-sweep-0.8.9~5 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1683c9a6c81c0f85a04a26c7259be74192d2f4de;p=sweep.git * (sweeprolog-predicate-completion-at-point): use holes for args --- 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