[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sweeprolog badc415fc1 2/2: FIXED: detecting end of clause
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sweeprolog badc415fc1 2/2: FIXED: detecting end of clause with inline comments ending with "." |
Date: |
Fri, 7 Oct 2022 05:59:17 -0400 (EDT) |
branch: elpa/sweeprolog
commit badc415fc164a1f8ff69af4e0b6e7833e9dfc049
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>
FIXED: detecting end of clause with inline comments ending with "."
---
NEWS.org | 11 ++++++++++-
sweeprolog-tests.el | 18 ++++++++++++++++++
sweeprolog.el | 8 ++++++--
3 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 19b030de97..e4b8d65828 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -11,6 +11,16 @@ SWI-Prolog in Emacs.
For further details, please consult the manual:
<https://eshelyaron.com/sweep.html>.
+* Version 0.5.2 on 2022-10-07
+
+** Fixed bug in detecting the end of a clause with commented fullstops
+
+This version includes a fix in ~sweeprolog-end-of-top-term~, which is
+used to locate the end of the current clause. Previously this
+function would get "confused" by in-clause comments that end with a
+fullstop (see the added test case in ~sweeprolog-test.el~ for an
+example). Reported by Jan Wielemaker.
+
* Version 0.5.0 on 2022-10-04
** New special buffer for listing and working with multiple top-levels
@@ -32,7 +42,6 @@ above command called ~sweeprolog-top-level-signal-current~
that operates
on the top-level thread of the current buffer. This command is also
newly bound to ~C-c C-c~ in top-level buffers.
-
** New command ~sweeprolog-document-predicate-at-point~ in ~sweeprolog-mode~
buffers
~sweeprolog-document-predicate-at-point~ is a new command available in
diff --git a/sweeprolog-tests.el b/sweeprolog-tests.el
index a294c5f601..c02f7e8751 100644
--- a/sweeprolog-tests.el
+++ b/sweeprolog-tests.el
@@ -53,6 +53,24 @@
(should (equal (sweeprolog-cut-query) t)))
+(ert-deftest fullstop-detection ()
+ "Tests detecting the fullstop in presence of confusing comments."
+ (with-temp-buffer
+ (sweeprolog-mode)
+ (insert "
+scasp_and_show(Q, Model, Tree) :-
+ scasp_mode(M0, T0),
+ setup_call_cleanup(
+ set_scasp_mode(Model, Tree),
+ ( scasp(Q, [])
+ ; false % make always nondet.
+ ),
+ set_scasp_mode(M0, T0)).
+")
+ (goto-char (point-min))
+ (sweeprolog-end-of-top-term)
+ (should (= (point) 252))))
+
(defun sweeprolog-test-indentation (given expected)
(with-temp-buffer
(sweeprolog-mode)
diff --git a/sweeprolog.el b/sweeprolog.el
index 6f071f1a99..7f68079d0c 100644
--- a/sweeprolog.el
+++ b/sweeprolog.el
@@ -6,7 +6,7 @@
;; Maintainer: Eshel Yaron <~eshel/dev@lists.sr.ht>
;; Keywords: prolog languages extensions
;; URL: https://git.sr.ht/~eshel/sweep
-;; Package-Version: 0.5.1
+;; Package-Version: 0.5.2
;; Package-Requires: ((emacs "28"))
;; This file is NOT part of GNU Emacs.
@@ -1708,7 +1708,11 @@ Interactively, a prefix arg means to prompt for BUFFER."
(forward-char))
(or (re-search-forward (rx "." (or white "\n")) nil t)
(goto-char (point-max)))
- (while (and (nth 8 (syntax-ppss)) (not (eobp)))
+ (while (and (or (nth 8 (syntax-ppss))
+ (save-excursion
+ (nth 8 (syntax-ppss (max (point-min)
+ (1- (point)))))))
+ (not (eobp)))
(while (and (nth 8 (syntax-ppss)) (not (eobp)))
(forward-char))
(or (re-search-forward (rx "." (or white "\n")) nil t)