[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sweeprolog e10568cfba 2/3: Have sweeprolog-top-level-signa
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sweeprolog e10568cfba 2/3: Have sweeprolog-top-level-signal-current call trace/0 by default |
Date: |
Sun, 20 Nov 2022 16:59:23 -0500 (EST) |
branch: elpa/sweeprolog
commit e10568cfba65678440470c0471128cf39149a4f7
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
Have sweeprolog-top-level-signal-current call trace/0 by default
* 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 | 14 +++++++++++---
sweeprolog.el | 19 ++++++++++++++++---
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/README.org b/README.org
index 6f7d38d0e3..41c48128cc 100644
--- a/README.org
+++ b/README.org
@@ -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
diff --git a/sweeprolog.el b/sweeprolog.el
index 567ee3babb..37698e8cdc 100644
--- a/sweeprolog.el
+++ b/sweeprolog.el
@@ -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