]> git.eshelyaron.com Git - sweep.git/commitdiff
ENHANCED: conditional syntax error highlighting
authorEshel Yaron <me@eshelyaron.com>
Thu, 17 Nov 2022 09:41:10 +0000 (11:41 +0200)
committerEshel Yaron <me@eshelyaron.com>
Thu, 17 Nov 2022 09:41:10 +0000 (11:41 +0200)
sweeprolog.el

index 58279bd5c109bdf96d023262949b83e58f47e2b9..8e25b30b968dd484e19d8efc46084802d749df6c 100644 (file)
@@ -1719,6 +1719,23 @@ resulting list even when found in the current clause."
   (with-silent-modifications
     (font-lock-unfontify-region beg end)))
 
+(defun sweeprolog-maybe-syntax-error-face (end)
+  (or (and (or (and sweeprolog--analyze-point
+                    (<= (save-excursion
+                          (goto-char sweeprolog--analyze-point)
+                          (sweeprolog-beginning-of-top-term)
+                          (1- (point)))
+                        (1+ end) sweeprolog--analyze-point))
+               (< (save-excursion
+                    (goto-char sweeprolog--analyze-point)
+                    (sweeprolog-end-of-top-term) (point))
+                  (save-excursion
+                    (goto-char sweeprolog--analyze-point)
+                    (sweeprolog-beginning-of-next-top-term) (point))
+                  (point-max)))
+           (sweeprolog-syntax-error-face))
+      (sweeprolog-around-syntax-error-face)))
+
 (defun sweeprolog-analyze-fragment-to-faces (beg end arg)
   (pcase arg
     (`("comment" . "structured")
@@ -1795,13 +1812,7 @@ resulting list even when found in the current clause."
            (setq cur (point)))
          (skip-chars-forward " \t\n")
          (push (list cur (point) nil) ws)
-         (let ((face (or (and (or (and sweeprolog--analyze-point
-                                       (<= end sweeprolog--analyze-point))
-                                  (< (save-excursion
-                                       (sweeprolog-end-of-top-term) (point))
-                                     (point-max)))
-                              (sweeprolog-syntax-error-face))
-                         (sweeprolog-around-syntax-error-face))))
+         (let ((face (sweeprolog-maybe-syntax-error-face end)))
            (cons (list beg (point) nil)
                  (append (list (list eb ee nil)
                                (list eb ee (sweeprolog-around-syntax-error-face))