]> git.eshelyaron.com Git - dict.git/commitdiff
Have sweeprolog-top-level-signal-current call trace/0 by default
authorEshel Yaron <me@eshelyaron.com>
Sun, 20 Nov 2022 21:21:39 +0000 (23:21 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 20 Nov 2022 21:21:39 +0000 (23:21 +0200)
* sweeprolog.el (sweeprolog-top-level-signal-default-goal): new user
option, set to "trace" by default.
(sweeprolog-top-level-signal-current): use it.

README.org
sweeprolog.el

index 6f7d38d0e3e8ac119336f578921426a8e4d7a812..41c48128cc230fbe0e5cc9c43ccb9f0f2d0141ab 100644 (file)
@@ -1235,16 +1235,24 @@ When executing long running Prolog queries in the top-level, there may
 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
index 567ee3babbe0df9ae3850634288c6cb4417de9b9..37698e8cdc28c3b918b23503d2d64f077b8a9cd8 100644 (file)
@@ -49,6 +49,8 @@
 
 (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)
@@ -323,7 +325,11 @@ buffer where the new predicate defintion should be inserted."
                  (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
 
@@ -2314,8 +2320,15 @@ Interactively, a prefix arg means to prompt for BUFFER."
                             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