diff options
author | Kyle Meyer <kyle@kyleam.com> | 2020-02-21 22:20:02 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2020-02-21 22:20:02 -0500 |
commit | 258b15c5e4aa6f49fb26ffc660bf523aeb927aaf (patch) | |
tree | 8aeff9e43f2d8d67a7712a72bfa8003a05eabf43 | |
parent | 3fcff2b92a4ac19d6f1dab3666dddcba46c4865b (diff) | |
parent | 5d5bb0109f6a84c0c191559ab71670fae4650e6a (diff) | |
download | snakemake-mode-258b15c5e4aa6f49fb26ffc660bf523aeb927aaf.tar.gz |
Merge branch 'emacs27-font-lock'
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | snakemake-mode.el | 52 |
2 files changed, 40 insertions, 15 deletions
@@ -4,6 +4,9 @@ NEWS -- history of user-visible changes -*- mode: org; -*- - The 'multiext' built-in (new in Snakemake v5.8.2) is now recognized. +- The font-lock handling has been updated to be compatible with + python.el changes in Emacs 27. + * v1.6.0 - Checkpoints (new in Snakemake v5.4) are now recognized. diff --git a/snakemake-mode.el b/snakemake-mode.el index e0299c2..255985c 100644 --- a/snakemake-mode.el +++ b/snakemake-mode.el @@ -431,20 +431,42 @@ embedded R, you need to set mmm-global-mode to a non-nil value such as 'maybe.") ;;; Mode -(defvar snakemake-font-lock-keywords - `((,snakemake-rule-or-subworkflow-re - (1 font-lock-keyword-face nil 'lax) - (2 font-lock-function-name-face nil 'lax) - (3 font-lock-keyword-face nil 'lax)) - (,(snakemake-rx line-start (one-or-more space) - (group field-key) - (zero-or-more space) ":") - 1 font-lock-type-face) - (,(snakemake-rx line-start (zero-or-more space) - (group sm-command) - (zero-or-more space) ":") - 1 font-lock-keyword-face) - (,(snakemake-rx (group sm-builtin)) 1 font-lock-builtin-face))) +(defvar snakemake--font-lock-keywords + `((,snakemake-rule-or-subworkflow-re + (1 font-lock-keyword-face nil 'lax) + (2 font-lock-function-name-face nil 'lax) + (3 font-lock-keyword-face nil 'lax)) + (,(snakemake-rx line-start (one-or-more space) + (group field-key) + (zero-or-more space) ":") + 1 font-lock-type-face) + (,(snakemake-rx line-start (zero-or-more space) + (group sm-command) + (zero-or-more space) ":") + 1 font-lock-keyword-face) + (,(snakemake-rx (group sm-builtin)) 1 font-lock-builtin-face))) + +(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" @@ -462,7 +484,7 @@ embedded R, you need to set mmm-global-mode to a non-nil value such as 'maybe.") #'snakemake-block-or-defun-name) (set (make-local-variable 'font-lock-defaults) - `(,(append snakemake-font-lock-keywords python-font-lock-keywords)))) + (cons snakemake-font-lock-keywords (cdr font-lock-defaults)))) ;;;###autoload (add-to-list 'auto-mode-alist '("Snakefile\\'" . snakemake-mode)) |