[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ediprolog cfcdf9e428: Merge remote-tracking branch 'ups
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ediprolog cfcdf9e428: Merge remote-tracking branch 'upstream/ediprolog/main' into externals/ediprolog |
Date: |
Wed, 26 Oct 2022 09:18:08 -0400 (EDT) |
branch: externals/ediprolog
commit cfcdf9e42821d246b7fbc84877aa4ecacc184a1c
Merge: 40c2693389 dc0e51ba57
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
Merge remote-tracking branch 'upstream/ediprolog/main' into
externals/ediprolog
---
README.md | 8 ++++----
ediprolog.el | 36 +++++++++++++++++++++++++-----------
factorial.png | Bin 60804 -> 39199 bytes
3 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index 406a356fd1..fdf591393d 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ After you have installed ediprolog, you can customize it with:
The two most important configuration options are:
- - `ediprolog-system`, either `scryer` or `swi`
+ - `ediprolog-system`, either `scryer` (default) or `swi`
- `ediprolog-program`, the path of the Prolog executable.
# Usage
@@ -51,11 +51,11 @@ Prolog process, and you interact with the process in the
current
buffer as on a terminal. Queries start with "?-" or ":-", possibly
preceded by "%" and whitespace. An example of a query is:
- %?- member(X, [a,b,c]).
+ %?- member(X, "abc").
If you press F10 when point is on that query, you get:
- %?- member(X, [a,b,c]).
+ %?- member(X, "abc").
%@ X = a
%@ ; X = b
%@ ; X = c
@@ -95,7 +95,7 @@ versions 26.1 and 27.0.50.
# Screenshot
Here is a sample interaction, using
-[CLP(FD) constraints](https://www.metalevel.at/prolog/clpfd) to
+[CLP(ℤ) constraints](https://www.metalevel.at/prolog/clpz) to
relate a number to its factorial:
![Factorial](factorial.png)
diff --git a/ediprolog.el b/ediprolog.el
index 1362a18354..9ded453544 100644
--- a/ediprolog.el
+++ b/ediprolog.el
@@ -4,7 +4,7 @@
;; Author: Markus Triska <triska@metalevel.at>
;; Keywords: languages, processes
-;; Version: 2.1
+;; Version: 2.2
;; Homepage: https://www.metalevel.at/ediprolog/
;; This file is free software; you can redistribute it and/or modify
@@ -39,7 +39,7 @@
;;
;; The two most important configuration options are:
;;
-;; - `ediprolog-system', either 'scryer or 'swi
+;; - `ediprolog-system', either 'scryer (default) or 'swi
;; - `ediprolog-program', the path of the Prolog executable.
;; Usage
@@ -53,11 +53,11 @@
;; Queries start with "?-" or ":-", possibly preceded by "%" and
;; whitespace. An example of a query is (without leading ";;"):
;;
-;; %?- member(X, [a,b,c]).
+;; %?- member(X, "abc").
;;
;; If you press F10 when point is on that query, you get:
;;
-;; %?- member(X, [a,b,c]).
+;; %?- member(X, "abc").
;; %@ X = a
;; %@ ; X = b
;; %@ ; X = c
@@ -93,7 +93,7 @@
;;; Code:
-(defconst ediprolog-version "2.1")
+(defconst ediprolog-version "2.2")
(defgroup ediprolog nil
"Transparent interaction with Prolog."
@@ -273,9 +273,9 @@ set_prolog_flag(toplevel_prompt, '%s').\n"
(ediprolog-prompt)))))
;; success (i.e., consulted without errors), or still an incomplete
;; line that starts with a comment character
(unless (or (string-match "^[\t ]*\\(?:%.*\\)?\\'" str)
- (let ((success "true."))
- (and (<= (length str) (length success))
- (string= str (substring success 0 (length str))))))
+ (string-prefix-p str "true.")
+ ;; newer versions of Scryer Prolog prepend 3 spaces to "true."
+ (string-prefix-p str " true."))
(setq ediprolog-consult-window (display-buffer ediprolog-consult-buffer))
(set-window-dedicated-p ediprolog-consult-window t)
(fit-window-to-buffer ediprolog-consult-window (/ (frame-height) 2))))
@@ -370,9 +370,19 @@ arguments, equivalent to `ediprolog-remove-interactions'."
(end-of-line)
(insert "\n" ediprolog-indent-prefix ediprolog-prefix)
(ediprolog-interact
- (format "%s\n" (mapconcat #'identity
+ (format "%s\n"
+ (if (eq ediprolog-system 'scryer)
+ ;; Scryer Prolog emits no additional indicators
+ ;; when a query spans multiple lines, so we send
+ ;; the query verbatim.
+ query
+ ;; For other Prolog systems, we merge the query into
+ ;; a single line. The drawback of this approach is
+ ;; that single-line comments at the end of a line are
+ ;; not handled correctly.
+ (mapconcat #'identity
;; `%' can precede each query line
- (split-string query "\n[ \t%]*") " ")))
+ (split-string query "\n[ \t%]*") " "))))
(when handle
(undo-amalgamate-change-group (cdr handle))))
t))
@@ -491,7 +501,11 @@ operates on the region."
(and buffer-file-name
(not (equal (file-remote-p ediprolog-temp-file)
(file-remote-p buffer-file-name)))))
- (setq ediprolog-temp-file (make-nearby-temp-file "ediprolog")))
+ (setq ediprolog-temp-file
+ (funcall (if (fboundp 'make-nearby-temp-file)
+ 'make-nearby-temp-file
+ 'make-temp-file)
+ "ediprolog")))
(let ((start (if (and transient-mark-mode mark-active)
(region-beginning) (point-min)))
(end (if (and transient-mark-mode mark-active)
diff --git a/factorial.png b/factorial.png
index b85c8c0f05..653a4df7d7 100644
Binary files a/factorial.png and b/factorial.png differ