From a5bf0ae66141e7560f70a045c0dea132a4868c87 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 12 Jun 2023 14:40:24 +0200 Subject: [PATCH] sh-script: improve fontification of RPM spec files Fontifiy only macros at line beginning as keywords, otherwise as variables. Add more accurate match for macros. * lisp/progmodes/sh-script.el (sh-font-lock-keywords-var): Add more accurate patterns for rpm macros. Also fontify parenthesized word after keyword. --- lisp/progmodes/sh-script.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/sh-script.el b/lisp/progmodes/sh-script.el index a305c35c5f8..cfc10878922 100644 --- a/lisp/progmodes/sh-script.el +++ b/lisp/progmodes/sh-script.el @@ -864,10 +864,13 @@ See `sh-feature'.") ("\\${?\\([[:alpha:]_][[:alnum:]_]*\\|[0-9]+\\|[$*_]\\)" 1 font-lock-variable-name-face)) (rpm sh-append rpm2 - ("%{?\\(\\sw+\\)" 1 font-lock-keyword-face)) + ("^\\s-*%\\(\\sw+\\)" 1 font-lock-keyword-face) + ("%{?\\([!?]*[[:alpha:]_][[:alnum:]_]*\\|[0-9]+\\|[%*#]\\*?\\|!?-[[:alpha:]]\\*?\\)" + 1 font-lock-variable-name-face)) (rpm2 sh-append shell ("^Summary:\\(.*\\)$" (1 font-lock-doc-face t)) - ("^\\(\\sw+\\):" 1 font-lock-variable-name-face))) + ("^\\(\\sw+\\)\\((\\(\\sw+\\))\\)?:" (1 font-lock-variable-name-face) + (3 font-lock-string-face nil t)))) "Default expressions to highlight in Shell Script modes. See `sh-feature'.") (defvar sh-font-lock-keywords-var-1 -- 2.39.2