From ec8ef75bc2183336e05b083337801745c4ac9546 Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Mon, 21 Nov 2022 20:39:33 +0200 Subject: [PATCH] Use new prolog_interrupt/0 to interrupt top-level threads * sweeprolog.el (sweeprolog-top-level-signal-default-goal): change default value to... * sweep.pl (sweep_interrupt/0): new predicate, backwards compatibility wrapper for prolog_interrupt/0. --- README.org | 9 ++++----- sweep.pl | 9 ++++++++- sweeprolog.el | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.org b/README.org index 41c4812..25e0fab 100644 --- a/README.org +++ b/README.org @@ -1248,11 +1248,10 @@ In ~sweeprolog-top-level-mode~ buffers, the command ~sweeprolog-top-level-signal-current~ is available for signaling the current top-level. It is bound by default to ~C-c C-c~. Normally, this command signals the goal specified by the user option -~sweeprolog-top-level-signal-default-goal~, which is set by default to -~trace~, causing the top-level thread to enter trace mode (see [[https://www.swi-prolog.org/pldoc/man?section=trace-summary-trace-mode][Trace -Mode in the SWI-Prolog manual]]). When called with a prefix argument -(~C-u C-c C-c~), ~sweeprolog-top-level-signal-current~ instead prompts for -a goal similarly to ~sweeprolog-top-level-signal~. +~sweeprolog-top-level-signal-default-goal~, which is set by default to a +predicate that interrupts the top-level thread returns control of the +top-level to the user. When ~sweeprolog-top-level-signal-current~ is +called with a prefix argument (~C-u C-c C-c~), it prompts for the goal. It is also possible to signal top-levels from the =sweep= Top-level Menu buffer with the command ~sweeprolog-top-level-menu-signal~ with point at diff --git a/sweep.pl b/sweep.pl index 1342485..61b69f9 100644 --- a/sweep.pl +++ b/sweep.pl @@ -66,7 +66,8 @@ sweep_atom_collection/2, sweep_context_callable/2, sweep_predicate_completion_candidates/2, - sweep_exportable_predicates/2 + sweep_exportable_predicates/2, + sweep_interrupt/0 ]). :- use_module(library(pldoc)). @@ -828,3 +829,9 @@ sweep_exportable_predicates(Path0, Preds) :- term_string(D1, D) ), Preds). + +:- if(current_predicate(prolog_interrupt/0)). +sweep_interrupt :- prolog_interrupt. +:- else. +sweep_interrupt :- trace. +:- endif. diff --git a/sweeprolog.el b/sweeprolog.el index cb6e9e2..fb22520 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -332,9 +332,9 @@ non-terminals)." (function :tag "Custom Function")) :group 'sweeprolog) -(defcustom sweeprolog-top-level-signal-default-goal "trace" +(defcustom sweeprolog-top-level-signal-default-goal "sweep_interrupt" "Prolog goal used by default for signaling top-level threads." - :package-version '((sweeprolog "0.8.10")) + :package-version '((sweeprolog "0.8.12")) :type 'string :group 'sweeprolog-top-level) -- 2.39.2