From 8f0e076b40447a1f555ddaa9138430a6c4f3438c Mon Sep 17 00:00:00 2001 From: Davide Masserut Date: Thu, 24 Aug 2023 00:53:22 +0200 Subject: [PATCH] Improve go-dot-work-mode font lock regexp All the go.work keywords are bounded by the beginning of line and whitespace so we use that as our regexp boundaries instead of word/symbol boundaries. --- go-mode.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/go-mode.el b/go-mode.el index 6003f715..b4e02d6e 100644 --- a/go-mode.el +++ b/go-mode.el @@ -2894,6 +2894,10 @@ If BUFFER, return the number of characters in that buffer instead." '("go" "toolchain" "use" "replace") "All keywords for go.work files. Used for font locking.") +(defvar go-dot-work-font-lock-keywords + `((,(concat "^\\s-*\\(" (regexp-opt go-dot-work-mode-keywords t) "\\)\\s-") 1 font-lock-keyword-face)) + "Keyword highlighting specification for `go-dot-work-mode'.") + ;;;###autoload (define-derived-mode go-dot-work-mode fundamental-mode "Go Work" "A major mode for editor go.work files." @@ -2904,7 +2908,7 @@ If BUFFER, return the number of characters in that buffer instead." (set (make-local-variable 'comment-start-skip) "\\(//+\\)\\s *") (set (make-local-variable 'font-lock-defaults) - '(go-dot-work-mode-keywords)) + '(go-dot-work-font-lock-keywords)) (set (make-local-variable 'indent-line-function) 'go-mode-indent-line) ;; Go style