arise a need to interrupt the query, either to inspect the state of
the top-level or to free it for running other queries. To signal a
=sweep= top-level that it should stop executing the current query and do
-something else instead, use the command ~M-x
-sweeprolog-top-level-signal~. This command prompts for an active =sweep=
+something else instead, use the command
+~sweeprolog-top-level-signal~. This command prompts for an active =sweep=
top-level buffer followed by a Prolog goal, and interrupts the
top-level causing it to run the specified goal.
#+KINDEX: C-c C-c (sweeprolog-top-level-mode)
+#+KINDEX: C-u C-c C-c (sweeprolog-top-level-mode)
#+FINDEX: sweeprolog-top-level-signal-current
+#+VINDEX: sweeprolog-top-level-signal-default-goal
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~.
+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~.
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
(defvar sweeprolog-read-module-history nil)
+(defvar sweeprolog-top-level-signal-goal-history nil)
+
(defvar sweeprolog-insert-term-functions
'(sweeprolog-maybe-insert-next-clause
sweeprolog-maybe-define-predicate)
(function :tag "Custom Function"))
:group 'sweeprolog)
-
+(defcustom sweeprolog-top-level-signal-default-goal "trace"
+ "Prolog goal used by default for signaling top-level threads."
+ :package-version '((sweeprolog "0.8.10"))
+ :type 'string
+ :group 'sweeprolog-top-level)
;;;; Keymaps
goal))
(defun sweeprolog-top-level-signal-current (goal)
- "Signal the current top-level thread to run GOAL."
- (interactive "MSignal goal: ?- " sweeprolog-top-level-mode)
+ "Signal the current top-level thread to run GOAL.
+
+Interactively, when called with a prefix argument, prompt for
+GOAL. Otherwise, GOAL is set to a default value specified by
+`sweeprolog-top-level-signal-default-goal'."
+ (interactive (list (if current-prefix-arg
+ (read-string "Signal goal: ?- " nil
+ sweeprolog-top-level-signal-goal-history)
+ sweeprolog-top-level-signal-default-goal)))
(sweeprolog-signal-thread sweeprolog-top-level-thread-id goal))
;;;###autoload