]> git.eshelyaron.com Git - sweep.git/commitdiff
FIXED: sweeprolog-end-of-top-term would get confused by "=.."
authorEshel Yaron <me@eshelyaron.com>
Mon, 10 Oct 2022 12:31:29 +0000 (15:31 +0300)
committerEshel Yaron <me@eshelyaron.com>
Mon, 10 Oct 2022 12:57:55 +0000 (15:57 +0300)
* sweeprolog.el: sweeprolog-end-of-top-term: don't stop after "=..".
* sweeprolog-tests.el: add unit test.

NEWS.org
README.org
sweeprolog-tests.el
sweeprolog.el

index 5417c116c4aaae674a932b31e0d70281d993a22e..139ae2d6f15f0cc92c76edff70cffe10cbf6d9d8 100644 (file)
--- a/NEWS.org
+++ b/NEWS.org
@@ -29,6 +29,13 @@ Wrapper around ~flymake-show-buffer-diagnostics~ for ~sweeprolog-mode~,
 bound to ~C-c C-`~.  With a prefix argument, calls
 ~flymake-show-project-diagnostics~ instead.
 
+** Fixed bug in end of a clause detection in presence of ~=..~
+
+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 occurrences of the ~=../2~ ("univ")
+operator in the clause's body.
+
 * Version 0.5.4 on 2022-10-09
 
 ** The manual now has a short description attached to each section
index 92959a3f54e4ca05fa0325c1652d4656606d6c38..408d339d71370efea3aaf15c3681b353aee513f0 100644 (file)
@@ -1264,10 +1264,6 @@ there some further improvements that we want to pursue:
   moving to the next predicate definition and ~C-c C-p~ for moving to
   the previous.
 
-- Integrate with ~flymake~ to provide on-the-fly diagnostics :: ~sweeprolog-mode~
-  should integrate with ~flymake~ to provide diagnostics and feedback
-  for errors in Prolog code in an Emacs-standard manner.
-
 - Improve the information provided for predicate completion candidates :: predicate
   completion with ~C-M-i~ should annotate each completion candidate with
   the names and modes of its arguments, when available.  E.g. say
index c02f7e87510dccf2d3e9a94140861187bca9df73..f3a7d5e7a6469fab45255d62e8ffe42c3463613e 100644 (file)
   (should (equal (sweeprolog-next-solution) nil))
   (should (equal (sweeprolog-cut-query) t)))
 
+(ert-deftest end-of-top-term-with-univ ()
+  "Tests detecting the fullstop in presence of `=..'."
+  (with-temp-buffer
+    (sweeprolog-mode)
+    (insert "
+html_program_section(Section, Dict) -->
+    { _{module:M, options:Options} :< Dict,
+      Content = Dict.get(Section),
+      Content \= [],
+      scasp_code_section_title(Section, Default, Title),
+      Opt =.. [Section,true],
+      option(Opt, Options, Default)
+    },
+    !,
+    html(h2(Title)),
+    (   {Section == query}
+    ->  {ovar_set_bindings(Dict.bindings)},
+        html_query(M:Content, Options)
+    ;   sequence(predicate_r(M:Options), Content)
+    ).
+")
+    (goto-char (point-min))
+    (sweeprolog-end-of-top-term)
+    (should (= (point) 466))))
+
 
 (ert-deftest fullstop-detection ()
   "Tests detecting the fullstop in presence of confusing comments."
index fccf3e6f26ad0f2f0710b812e8d98707edba44cb..28c07f80f6e37a72b9e31291c1cb3e0592fdd289 100644 (file)
@@ -1817,7 +1817,10 @@ Interactively, a prefix arg means to prompt for BUFFER."
     (while (and (or (nth 8 (syntax-ppss))
                     (save-excursion
                       (nth 8 (syntax-ppss (max (point-min)
-                                               (1- (point)))))))
+                                               (1- (point))))))
+                    (save-match-data
+                      (looking-back (rx "=.." (or white "\n"))
+                                    (line-beginning-position))))
                 (not (eobp)))
       (while (and (nth 8 (syntax-ppss)) (not (eobp)))
         (forward-char))