From e4751a951a53c4d4610b2eb17469a21177cab6bc Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Mon, 3 Feb 2025 21:01:20 -0500 Subject: [PATCH] snakemake-rx: Use rx-let instead of obsolete rx-constituents rx-constituents has been declared as obsolete in the upcoming Emacs 30.1. Follow the change to python-rx [*] (on which snakemake-rx is based) and switch to using rx-let. Bump the minimum Emacs requirement from 26.1 to 27.1 because rx-let isn't available until 27.1 (released in 2020). [*] 2aed0430c7c (Use new-style rx extensions in python.el, 2019-10-28) --- .github/workflows/test.yml | 1 - NEWS | 2 + snakemake-mode.el | 170 +++++++++++++++++-------------------- 3 files changed, 82 insertions(+), 91 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7917461..57a86dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,6 @@ jobs: strategy: matrix: emacs_version: - - 26.1 - 27.2 - 28.2 - 29.4 diff --git a/NEWS b/NEWS index 57b49dc..e9f439d 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ NEWS -- history of user-visible changes -*- mode: org; -*- * master (unreleased) +- The minimum required Emacs is now 27.1. + - The 'localrule' keyword (new in Snakemake v7.25.0) is now recognized. diff --git a/snakemake-mode.el b/snakemake-mode.el index fd4763a..ffdb4f1 100644 --- a/snakemake-mode.el +++ b/snakemake-mode.el @@ -6,7 +6,7 @@ ;; URL: https://git.kyleam.com/snakemake-mode/about ;; Keywords: tools ;; Version: 2.0.0 -;; Package-Requires: ((emacs "26.1") (transient "0.3.0")) +;; Package-Requires: ((emacs "27.1") (transient "0.3.0")) ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -73,95 +73,85 @@ ;;; Regexp -(eval-and-compile - (defconst snakemake-rx-constituents - `((named-rule . ,(rx (and (group - symbol-start - (or "checkpoint" "module" "rule" "subworkflow")) - " " - (group (one-or-more - (or (syntax word) (syntax symbol))))))) - (anon-rule . ,(rx symbol-start "rule")) - (field-key . ,(rx symbol-start - (or "benchmark" - "cache" - "conda" - "container" - "cwl" - "default_target" - "envmodules" - "group" - "handover" - "input" - "localrule" - "log" - "message" - "name" - "notebook" - "output" - "params" - "priority" - "resources" - "run" - "script" - "shadow" - "shell" - "singularity" - "threads" - "version" - "wildcard_constraints" - "wrapper" - ;; Keys for subworkflow blocks - "configfile" - "snakefile" - "workdir") - symbol-end)) - (sm-command . ,(rx symbol-start - (or "configfile" - "container" - "containerized" - "envvars" - "include" - "localrules" - "onerror" - "onsuccess" - "report" - "ruleorder" - "singularity" - "wildcard_constraints" - "workdir") - symbol-end)) - (sm-builtin . ,(rx symbol-start - (or "ancient" - "checkpoints" - "directory" - "dynamic" - "expand" - "input" - "multiext" - "output" - "params" - "pipe" - "protected" - "report" - "shell" - "temp" - "touch" - "unpack" - "wildcards") - symbol-end))) - "Snakemake-specific sexps for `snakemake-rx'.") - - (defmacro snakemake-rx (&rest regexps) - "Specialized `rx' for Snakemake mode." - ;; Modified from `python-rx'. - (let ((rx-constituents (append snakemake-rx-constituents rx-constituents))) - (cond ((null regexps) - (error "No regexp")) - ((cdr regexps) - (rx-to-string `(and ,@regexps) t)) - (t - (rx-to-string (car regexps) t)))))) +(defmacro snakemake-rx (&rest regexps) + "Specialized `rx' for Snakemake mode." + ;; Modified from `python-rx'. + `(rx-let ((named-rule (and (group + symbol-start + (or "checkpoint" "module" "rule" "subworkflow")) + " " + (group (one-or-more + (or (syntax word) (syntax symbol)))))) + (anon-rule (and symbol-start "rule")) + (field-key (and symbol-start + (or "benchmark" + "cache" + "conda" + "container" + "cwl" + "default_target" + "envmodules" + "group" + "handover" + "input" + "localrule" + "log" + "message" + "name" + "notebook" + "output" + "params" + "priority" + "resources" + "run" + "script" + "shadow" + "shell" + "singularity" + "threads" + "version" + "wildcard_constraints" + "wrapper" + ;; Keys for subworkflow blocks + "configfile" + "snakefile" + "workdir") + symbol-end)) + (sm-command (and symbol-start + (or "configfile" + "container" + "containerized" + "envvars" + "include" + "localrules" + "onerror" + "onsuccess" + "report" + "ruleorder" + "singularity" + "wildcard_constraints" + "workdir") + symbol-end)) + (sm-builtin (and symbol-start + (or "ancient" + "checkpoints" + "directory" + "dynamic" + "expand" + "input" + "multiext" + "output" + "params" + "pipe" + "protected" + "report" + "shell" + "temp" + "touch" + "unpack" + "wildcards") + symbol-end))) + (rx ,@regexps))) (defconst snakemake-rule-or-subworkflow-re (snakemake-rx line-start (zero-or-more space)