From: Eshel Yaron Date: Fri, 7 Oct 2022 09:44:08 +0000 (+0300) Subject: FIXED: detecting end of clause with inline comments ending with "." X-Git-Tag: V8.5.18-sweep-0.6.0~6 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=badc415fc164a1f8ff69af4e0b6e7833e9dfc049;p=dict.git FIXED: detecting end of clause with inline comments ending with "." --- diff --git a/NEWS.org b/NEWS.org index 19b030d..e4b8d65 100644 --- a/NEWS.org +++ b/NEWS.org @@ -11,6 +11,16 @@ SWI-Prolog in Emacs. For further details, please consult the manual: . +* 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 a294c5f..c02f7e8 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 6f071f1..7f68079 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)