From 2b7e3aa00afebe454bea26f54d31847e178c3c33 Mon Sep 17 00:00:00 2001 From: Alex Kost Date: Wed, 16 Sep 2015 21:34:24 +0300 Subject: Add 'geiser-syntax--simple-keywords' Use this function instead of repeating the same code in each implementation. --- elisp/geiser-chicken.el | 2 +- elisp/geiser-guile.el | 4 +--- elisp/geiser-racket.el | 5 +---- elisp/geiser-syntax.el | 6 ++++++ 4 files changed, 9 insertions(+), 8 deletions(-) (limited to 'elisp') diff --git a/elisp/geiser-chicken.el b/elisp/geiser-chicken.el index c086b17..135d345 100644 --- a/elisp/geiser-chicken.el +++ b/elisp/geiser-chicken.el @@ -207,7 +207,7 @@ This function uses `geiser-chicken-init-file' if it exists." ;;; Keywords and syntax (defun geiser-chicken--keywords () - `((,(format "[[(]%s\\>" (regexp-opt geiser-chicken-builtin-keywords 1)) . 1))) + (geiser-syntax--simple-keywords geiser-chicken-builtin-keywords)) (geiser-syntax--scheme-indent (receive 2) diff --git a/elisp/geiser-guile.el b/elisp/geiser-guile.el index e8eb11a..941fe81 100644 --- a/elisp/geiser-guile.el +++ b/elisp/geiser-guile.el @@ -247,9 +247,7 @@ This function uses `geiser-guile-init-file' if it exists." (defun geiser-guile--keywords () (append - (when geiser-guile-extra-keywords - `((,(format "[[(]%s\\>" (regexp-opt geiser-guile-extra-keywords 1)) - . 1))) + (geiser-syntax--simple-keywords geiser-guile-extra-keywords) `((,(rx "(" (group "define-once") eow (* space) (? (group (+ word)))) (1 font-lock-keyword-face) (2 font-lock-variable-name-face nil t)) diff --git a/elisp/geiser-racket.el b/elisp/geiser-racket.el index 6a849e3..23c6083 100644 --- a/elisp/geiser-racket.el +++ b/elisp/geiser-racket.el @@ -272,10 +272,7 @@ using start-geiser, a procedure in the geiser/server module." (defun geiser-racket--keywords () (append geiser-racket-font-lock-forms - (when geiser-racket-extra-keywords - `((,(format "[[(]%s\\>" - (regexp-opt geiser-racket-extra-keywords 1)) - . 1))))) + (geiser-syntax--simple-keywords geiser-racket-extra-keywords))) (geiser-syntax--scheme-indent (begin0 1) diff --git a/elisp/geiser-syntax.el b/elisp/geiser-syntax.el index 9557f5e..bc110d9 100644 --- a/elisp/geiser-syntax.el +++ b/elisp/geiser-syntax.el @@ -60,6 +60,12 @@ (2 font-lock-function-name-face nil t)) (,(rx "(" (group "when") eow) . 1))) +(defun geiser-syntax--simple-keywords (keywords) + "Return `font-lock-keywords' to highlight scheme KEYWORDS. +KEYWORDS should be a list of strings." + (when keywords + `((,(format "[[(]%s\\>" (regexp-opt keywords 1)) . 1)))) + (font-lock-add-keywords 'scheme-mode geiser-syntax--keywords) (geiser-impl--define-caller geiser-syntax--impl-kws keywords () -- cgit v1.2.3