[A68-MODE][COMMITTED] Font-lock string breaks only within strings
Jose E. Marchesi
jemarch@gnu.org
Fri May 23 22:12:02 GMT 2025
---
a68-mode.el | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/a68-mode.el b/a68-mode.el
index 8dbeb47..0a8b269 100644
--- a/a68-mode.el
+++ b/a68-mode.el
@@ -211,12 +211,25 @@
;;;; Font-lock keywords.
+(defun a68--string-matcher (re end)
+ "Search for a regexp within Algol 68 strings."
+ (let (pos (case-fold-search t))
+ (while (and (setq pos (re-search-forward re end t))
+ (not (a68-within-string))))
+ pos))
+
+(defun a68--string-break-matcher (end)
+ (a68--string-matcher "\\('[nrft']\\)\\|\\('(.*?)\\)" end))
+
+(defun a68--bad-string-break-matcher (end)
+ (a68--string-matcher "\\(''\\|[^']\\)\\('[^nrft'(]\\)" end))
+
(defconst a68-font-lock-keywords-common
(list
;; String breaks. Apostrophe is not (currently) a worthy character
;; out of strings, so for now we can just match it anywhere.
- '("\\('[nrft']\\)\\|\\('(.*?)\\)" 0 ''a68-string-break-face prepend)
- '("\\(''\\|[^']\\)\\('[^nrft'(]\\)" 2 ''font-lock-warning-face prepend)
+ '(a68--string-break-matcher 0 ''a68-string-break-face t)
+ '(a68--bad-string-break-matcher 2 ''font-lock-warning-face t)
;; Two or more consecutive underscore characters are always
;; illegal in this stropping regime.
(cons "_[_]+" ''font-lock-warning-face))
--
2.30.2
More information about the Algol68
mailing list