From 8a0ca12bbada5c44ac5c820aa217f09327b1f30a Mon Sep 17 00:00:00 2001 From: Eshel Yaron Date: Thu, 17 Nov 2022 11:41:10 +0200 Subject: [PATCH] ENHANCED: conditional syntax error highlighting --- sweeprolog.el | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/sweeprolog.el b/sweeprolog.el index 58279bd..8e25b30 100644 --- a/sweeprolog.el +++ b/sweeprolog.el @@ -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)) -- 2.39.2