From 5c9873c39222e8d54afc9e63d1148ae1a822fbda Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 16 Apr 2016 17:03:07 -0400 Subject: Support anonymous rule blocks --- NEWS | 2 ++ snakemake-mode.el | 15 +++++++++------ snakemake.el | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 46428f7..e9a937e 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,8 @@ NEWS -- history of user-visible changes -*- mode: org; -*- - ".snakefile" has been added as a suffix for Snakemake files. +- Anonymous rule blocks are now supported. + * v0.3.0 ** New features diff --git a/snakemake-mode.el b/snakemake-mode.el index 319a0d8..56052d1 100644 --- a/snakemake-mode.el +++ b/snakemake-mode.el @@ -70,10 +70,11 @@ ;;; Regexp (defconst snakemake-rule-or-subworkflow-re - (rx (group symbol-start (or "rule" "subworkflow")) - " " - (group (one-or-more (or (syntax word) (syntax symbol)))) - ":") + (rx (or (and (group symbol-start (or "rule" "subworkflow")) + " " + (group (one-or-more (or (syntax word) (syntax symbol)))) + ":") + (and (group symbol-start "rule") ":"))) "Regexp matching a rule or subworkflow.") (defconst snakemake-rule-or-subworkflow-line-re @@ -326,8 +327,10 @@ label." ;;; Mode (defvar snakemake-font-lock-keywords - `((,snakemake-rule-or-subworkflow-line-re (1 font-lock-keyword-face) - (2 font-lock-function-name-face)) + `((,snakemake-rule-or-subworkflow-line-re + (1 font-lock-keyword-face nil 'lax) + (2 font-lock-function-name-face nil 'lax) + (3 font-lock-keyword-face nil 'lax)) (,snakemake-toplevel-command-re 1 font-lock-keyword-face) (,snakemake-builtin-function-re 1 font-lock-builtin-face) (,snakemake-field-key-indented-re 1 font-lock-type-face))) diff --git a/snakemake.el b/snakemake.el index c3f5ec4..20ec2cd 100644 --- a/snakemake.el +++ b/snakemake.el @@ -299,7 +299,7 @@ currently limited to a single-item list." (save-excursion (end-of-line) (re-search-backward snakemake-rule-or-subworkflow-re) - (let ((rule (and (equal (match-string-no-properties 1) "rule") + (let ((rule (and (string= (match-string-no-properties 1) "rule") (match-string-no-properties 2)))) (and (or (not targets-only) (snakemake-check-target rule)) (list rule)))))) -- cgit v1.2.3