From 3a2f156acd41162fd6a030ec66bb979c0e5c4846 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 10 Jul 2019 02:27:42 +0200 Subject: [PATCH] lang/sh: extract extra fontification into hook So it can apply to sh-mode derivatives, like direnv-envrc-mode. --- modules/lang/sh/config.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/lang/sh/config.el b/modules/lang/sh/config.el index 3e64a59f4..ed0f1c5da 100644 --- a/modules/lang/sh/config.el +++ b/modules/lang/sh/config.el @@ -34,14 +34,16 @@ ;; 1. Fontifies variables in double quotes ;; 2. Fontify command substitution in double quotes ;; 3. Fontify built-in/common commands (see `+sh-builtin-keywords') - (font-lock-add-keywords - 'sh-mode `((+sh--match-variables-in-quotes - (1 'font-lock-constant-face prepend) - (2 'font-lock-variable-name-face prepend)) - (+sh--match-command-subst-in-quotes - (1 'sh-quoted-exec prepend)) - (,(regexp-opt +sh-builtin-keywords 'words) - (0 'font-lock-type-face append)))) + (defun +sh|init-extra-fontification () + (font-lock-add-keywords + nil `((+sh--match-variables-in-quotes + (1 'font-lock-constant-face prepend) + (2 'font-lock-variable-name-face prepend)) + (+sh--match-command-subst-in-quotes + (1 'sh-quoted-exec prepend)) + (,(regexp-opt +sh-builtin-keywords 'words) + (0 'font-lock-type-face append))))) + (add-hook 'sh-mode-hook #'+sh|init-extra-fontification) ;; 4. Fontify delimiters by depth (add-hook 'sh-mode-hook #'rainbow-delimiters-mode)