emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/sweeprolog 3c0eda9c0e 2/5: FIXED: tokenizing adjacent oper


From: ELPA Syncer
Subject: [nongnu] elpa/sweeprolog 3c0eda9c0e 2/5: FIXED: tokenizing adjacent operators
Date: Fri, 26 May 2023 06:02:41 -0400 (EDT)

branch: elpa/sweeprolog
commit 3c0eda9c0e63c34a3e24d7a7800895364a138a38
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>

    FIXED: tokenizing adjacent operators
    
    Make Sweep's Prolog tokenization functions more careful in their
    handling of unrelated adjacent operators.  This fixes an issue that
    affects term-based movement commands and other commands that rely on
    'sweeprolog--forward-sexp' and friends.
    
    * sweeprolog.el (sweeprolog-next-token-boundaries)
    (sweeprolog-last-token-boundaries): Fix handling of
    adjacent (distinct) operators.
    
    * sweeprolog-tests.el
    (forward-sexp-with-adjacent-operators): New test case.
---
 sweeprolog-tests.el | 12 ++++++++++++
 sweeprolog.el       | 20 +++++++++++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/sweeprolog-tests.el b/sweeprolog-tests.el
index 48b35cefd3..2748ee01c5 100644
--- a/sweeprolog-tests.el
+++ b/sweeprolog-tests.el
@@ -1791,4 +1791,16 @@ head,
     body.
 "))
 
+(ert-deftest forward-sexp-with-adjacent-operators ()
+  "Tests detecting the fullstop in presence of `.=.'."
+  (with-temp-buffer
+    (sweeprolog-mode)
+    (insert "a,+b.")
+    (goto-char (point-min))
+    (sweeprolog--forward-sexp)
+    (should (= (point) 2))
+    (goto-char (point-max))
+    (sweeprolog--backward-sexp)
+    (should (= (point) 4))))
+
 ;;; sweeprolog-tests.el ends here
diff --git a/sweeprolog.el b/sweeprolog.el
index 457413489e..39f5c90b9b 100644
--- a/sweeprolog.el
+++ b/sweeprolog.el
@@ -3800,7 +3800,14 @@ work."
            ((or (= syn ?.)
                 (= syn ?\\))
             (skip-syntax-forward ".")
-            (list 'operator beg (point)))
+            (let ((end (point)))
+              (while (and (< beg (point))
+                          (not (sweeprolog--query-once
+                                "sweep" "sweep_op_info"
+                                (cons (buffer-substring-no-properties beg 
(point))
+                                      (buffer-file-name)))))
+                (forward-char -1))
+              (list 'operator beg (if (= beg (point)) end (point)))))
            ((= syn ?\()
             (list 'open beg (point)))
            ((= syn ?\))
@@ -3836,9 +3843,16 @@ work."
             (skip-syntax-backward "w_")
             (list 'functor (point) end))
            ((or (= syn ?.)
-                (= syn ?\\))  ; specifically, the backslash character
+                (= syn ?\\))   ; specifically, the backslash character
             (skip-syntax-backward ".")
-            (list 'operator (point) end))
+            (let ((beg (point)))
+              (while (and (< (point) end)
+                          (not (sweeprolog--query-once
+                                "sweep" "sweep_op_info"
+                                (cons (buffer-substring-no-properties (point) 
end)
+                                      (buffer-file-name)))))
+                (forward-char 1))
+              (list 'operator (if (= end (point)) beg (point)) end)))
            ((= syn ?\()
             (list 'open (1- end) end))
            ((= syn ?\))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]