From 3e5f73c259b6134bce6b4fd01830833a3f585cef Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 22 Feb 2022 21:06:07 -0500 Subject: mode: Add support for new module syntax Snakemake 6.0 introduced a module syntax that looks like this: module other_workflow: snakefile: "other_workflow/Snakefile" use rule * from other_workflow as other_* Give the new module block the same indentation and fontification as other blocks by adding "module" to the list of words that mark a named rule. For the "use rule" line, highlight "use rule" as a keyword, leaving the rest of the line to be highlighted by python.el. --- NEWS | 2 ++ snakemake-mode.el | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 92bac63..fe29839 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ NEWS -- history of user-visible changes -*- mode: org; -*- by ~--cores~ to follow upstream changes. ~--cores~ is bound to ~-c~, and ~--use-conda~ has been moved from ~-c~ to ~-C~. +- Snakemake's new module syntax (added in v6.0) is now supported. + - Additional Snakemake keywords are now recognized: 'containerized' (new in Snakemake v6.0.0), 'default_target' (new in Snakemake v6.15.0), 'handover' (new in Snakemake v6.2.0), 'name' (new in diff --git a/snakemake-mode.el b/snakemake-mode.el index e87c25a..8694762 100644 --- a/snakemake-mode.el +++ b/snakemake-mode.el @@ -75,8 +75,9 @@ (eval-and-compile (defconst snakemake-rx-constituents - `((named-rule . ,(rx (and (group symbol-start - (or "checkpoint" "rule" "subworkflow")) + `((named-rule . ,(rx (and (group + symbol-start + (or "checkpoint" "module" "rule" "subworkflow")) " " (group (one-or-more (or (syntax word) (syntax symbol))))))) @@ -452,6 +453,7 @@ embedded R, you need to set mmm-global-mode to a non-nil value such as 'maybe.") (group sm-command) (zero-or-more space) ":") 1 font-lock-keyword-face) + (,(rx line-start (group "use rule ")) 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) -- cgit v1.2.3