aboutsummaryrefslogtreecommitdiff
path: root/snakemake-mode.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2020-02-21 00:42:38 -0500
committerKyle Meyer <kyle@kyleam.com>2020-02-21 22:19:39 -0500
commit5d5bb0109f6a84c0c191559ab71670fae4650e6a (patch)
tree8aeff9e43f2d8d67a7712a72bfa8003a05eabf43 /snakemake-mode.el
parent8e8db653aa3a1ddf0afd19f2eea8656ce6c76c61 (diff)
downloadsnakemake-mode-5d5bb0109f6a84c0c191559ab71670fae4650e6a.tar.gz
font-lock: Adjust python-font-lock-keywords handling for Emacs 27
In Emacs 27, specifically 36b64e087e (Add 'font-lock-maximum-decoration' levels for Python, 2018-07-19), python-font-lock-keywords was changed to a list of symbols that define different fontification levels, so we can no longer simply tack snakemake-font-lock-keywords onto it. Instead define a set of levels that mirrors Python mode's. For Snakemake mode, the same decoration is used for all levels, but at least we will honor the level of decoration that the user has set for Python. Reported-by: Nicholas Knoblauch <nwknoblauch@gmail.com> Closes #29.
Diffstat (limited to 'snakemake-mode.el')
-rw-r--r--snakemake-mode.el23
1 files changed, 21 insertions, 2 deletions
diff --git a/snakemake-mode.el b/snakemake-mode.el
index 7987304..255985c 100644
--- a/snakemake-mode.el
+++ b/snakemake-mode.el
@@ -446,8 +446,27 @@ embedded R, you need to set mmm-global-mode to a non-nil value such as 'maybe.")
1 font-lock-keyword-face)
(,(snakemake-rx (group sm-builtin)) 1 font-lock-builtin-face)))
-(defvar snakemake-font-lock-keywords
- (append snakemake--font-lock-keywords python-font-lock-keywords))
+(if (bound-and-true-p python-font-lock-keywords-level-1)
+ (with-no-warnings
+ ;; In Emacs 27 `python-font-lock-keywords' was split up into
+ ;; different decoration levels.
+ (defvar snakemake-font-lock-keywords-level-1
+ (append snakemake--font-lock-keywords
+ python-font-lock-keywords-level-1))
+ (defvar snakemake-font-lock-keywords-level-2
+ (append snakemake--font-lock-keywords
+ python-font-lock-keywords-level-2))
+ (defvar snakemake-font-lock-keywords-maximum-decoration
+ (append snakemake--font-lock-keywords
+ python-font-lock-keywords-maximum-decoration))
+ (defvar snakemake-font-lock-keywords
+ ;; Mirrors `python-font-lock-keywords'.
+ '(snakemake-font-lock-keywords-level-1
+ snakemake-font-lock-keywords-level-1
+ snakemake-font-lock-keywords-level-2
+ snakemake-font-lock-keywords-maximum-decoration)))
+ (defvar snakemake-font-lock-keywords
+ (append snakemake--font-lock-keywords python-font-lock-keywords)))
;;;###autoload
(define-derived-mode snakemake-mode python-mode "Snakemake"