[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sweeprolog db7ef44a61 083/166: DOC: add manual section abo
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sweeprolog db7ef44a61 083/166: DOC: add manual section about setting Prolog flags |
Date: |
Fri, 30 Sep 2022 04:59:28 -0400 (EDT) |
branch: elpa/sweeprolog
commit db7ef44a61c2771f336f474ac43e9d4b80668fea
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
DOC: add manual section about setting Prolog flags
---
README.org | 39 +++++++++++++++++++++++++++++++++++++++
sweep.el | 8 ++++++--
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/README.org b/README.org
index 819fa37794..f3f37ec2e5 100644
--- a/README.org
+++ b/README.org
@@ -429,6 +429,9 @@ accessed from anywhere with =C-c p t=, which invokes the
command
=sweep-top-level=.
* Examining Prolog messages
+:PROPERTIES:
+:CUSTOM_ID: prolog-messages
+:END:
#+CINDEX: messages
#+VINDEX: sweep-messages-buffer-name
@@ -449,6 +452,42 @@ buffer. For more information about the features enabled by
to the =sweep= messages buffer. This command is bound by default in
=sweep-prefix-map= to the =e= key (see [[Quick access to =sweep= commands]]).
+* Setting Prolog flags
+:PROPERTIES:
+:CUSTOM_ID: prolog-flags
+:END:
+
+#+CINDEX: prolog flags
+#+FINDEX: sweep-set-prolog-flag
+The command =M-x sweep-set-prolog-flag= can be used to interactively
+configure the embedded Prolog execution environment by changing the
+values of Prolog flags. This command first prompts the user for a
+Prolog flag to set, with completion candidates annotated with their
+current values as Prolog flags, and then prompts for a string that
+will be read as a Prolog term and set as the value of the chosen flag.
+For more information on Prolog flags in SWI-Prolog see
[[https://www.swi-prolog.org/pldoc/man?section=flags][Environment
+Control in the SWI-Prolog manual]].
+
+As an example, the Prolog flag =double_quotes= controls the
+interpretation of double quotes in Prolog code. By default,
+=double_quotes= is set to =string=, so e.g. ="foo"= is read as a SWI-Prolog
+string as we can easily validate in the =sweep= top-level:
+
+#+begin_src prolog
+?- A = "foo".
+A = "foo".
+#+end_src
+
+We can change the interpretation of double quotes to denote lists of
+character codes, by setting the value the =double_quotes= flag to =codes=
+with =M-x sweep-set-prolog-flag RET double_quotes RET codes RET=.
+Evaluating =A = "foo"= again exhibits the different interpretation:
+
+#+begin_src prolog
+?- A = "foo".
+A = [102, 111, 111].
+#+end_src
+
* Installing Prolog packages
:PROPERTIES:
:CUSTOM_ID: prolog-packages
diff --git a/sweep.el b/sweep.el
index 0778c7fb1c..6ab1d6c34a 100644
--- a/sweep.el
+++ b/sweep.el
@@ -200,6 +200,8 @@ is used to find a the swipl executable."
(completing-read sweep-read-flag-prompt col)))
(defun sweep-set-prolog-flag (flag value)
+ "Set the Prolog flag FLAG to VALUE.
+FLAG and VALUE are specified as strings and read as Prolog terms."
(interactive (let ((f (sweep-read-prolog-flag)))
(list f (read-string (concat "Set " f " to: ")))))
(sweep-open-query "user"
@@ -208,8 +210,9 @@ is used to find a the swipl executable."
(cons flag value))
(let ((sol (sweep-next-solution)))
(sweep-close-query)
- (when (sweep-true-p sol)
- (cdr sol))))
+ (if (sweep-true-p sol)
+ (message "Prolog flag %s set to %s" flag value)
+ (user-error "Setting %s to %s failed" flag value))))
(defun sweep-setup-message-hook ()
(with-current-buffer (get-buffer-create sweep-messages-buffer-name)
@@ -928,6 +931,7 @@ Interactively, a prefix arg means to prompt for BUFFER."
(define-key map "p" #'sweep-find-predicate)
(define-key map "t" #'sweep-top-level)
(define-key map "P" #'sweep-pack-install)
+ (define-key map "F" #'sweep-set-prolog-flag)
(define-key map "e" #'sweep-view-messages)
map)
"Keymap for `sweep' global commands.")
- [nongnu] elpa/sweeprolog 5c4aef50f2 041/166: Run `ninja install` as root in CI, (continued)
- [nongnu] elpa/sweeprolog 5c4aef50f2 041/166: Run `ninja install` as root in CI, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog a6e37f306b 069/166: ENHANCED: fontify mutlifile predicate calls in a dedicated face, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 4299c39d62 070/166: ENHANCED: indentation edge cases handling, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 1a19f7b3be 074/166: DOC: document font-lock and xref integration for sweep-mode, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 1c6d2e96a8 078/166: ENHANCED: allow user to specify location of swipl binary, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 5a8f70149f 099/166: FIXED: (sweep-load-buffer): error after prompting for a buffer, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 7327016d15 095/166: FIXED: sweep_predicates_collection/2: include preds defined in user, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog a70a730f48 087/166: PORT: don't use the 2nd arg to looking-at, added only in Emacs 29, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog d1a2913f75 115/166: ENHANCED: Update semantic highlighting on idle timer in sweep-mode, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog b168465391 098/166: FIXED: sweep_load_buffer/3: load files in the context of "user", ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog db7ef44a61 083/166: DOC: add manual section about setting Prolog flags,
ELPA Syncer <=
- [nongnu] elpa/sweeprolog 521a4bfde5 132/166: BUILD: replaced Makefile with CMakeLists.txt, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog ecf601dd54 133/166: FIXED: indentation error when typing at end of buffer, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 7bca15bd1e 141/166: DOC: fix copy-paste error in README.org, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 83bbd58031 153/166: ADDED: new command sweeprolog-restart for resetting sweep, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog a369e46143 160/166: ENHANCED: underline occurrences of the variable at point, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 8d13f21c0d 162/166: ADDED: new command sweeprolog-highlight-variable, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 3d5d0deda5 161/166: ADDED: new user option sweeprolog-enable-cursor-sensor, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog 8f0e4a644d 164/166: FIXED: error on interactively removing variable highlighting, ELPA Syncer, 2022/09/30
- [nongnu] elpa/sweeprolog b43b6019ff 154/166: DOC: document the newly added sweeprolog-restart command, ELPA Syncer, 2022/09/30