Skip to content

Commit 715f162

Browse files
committed
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)
1 parent 8f34adf commit 715f162

File tree

3 files changed

+82
-91
lines changed

3 files changed

+82
-91
lines changed

.github/workflows/test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ jobs:
66
strategy:
77
matrix:
88
emacs_version:
9-
- 26.1
109
- 27.2
1110
- 28.2
1211
- 29.4

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ NEWS -- history of user-visible changes -*- mode: org; -*-
22

33
* master (unreleased)
44

5+
- The minimum required Emacs is now 27.1.
6+
57
- The 'localrule' keyword (new in Snakemake v7.25.0) is now
68
recognized.
79

snakemake-mode.el

Lines changed: 80 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
;; URL: https://git.kyleam.com/snakemake-mode/about
77
;; Keywords: tools
88
;; Version: 2.0.0
9-
;; Package-Requires: ((emacs "26.1") (transient "0.3.0"))
9+
;; Package-Requires: ((emacs "27.1") (transient "0.3.0"))
1010

1111
;; This program is free software; you can redistribute it and/or modify
1212
;; it under the terms of the GNU General Public License as published by
@@ -73,95 +73,85 @@
7373

7474
;;; Regexp
7575

76-
(eval-and-compile
77-
(defconst snakemake-rx-constituents
78-
`((named-rule . ,(rx (and (group
79-
symbol-start
80-
(or "checkpoint" "module" "rule" "subworkflow"))
81-
" "
82-
(group (one-or-more
83-
(or (syntax word) (syntax symbol)))))))
84-
(anon-rule . ,(rx symbol-start "rule"))
85-
(field-key . ,(rx symbol-start
86-
(or "benchmark"
87-
"cache"
88-
"conda"
89-
"container"
90-
"cwl"
91-
"default_target"
92-
"envmodules"
93-
"group"
94-
"handover"
95-
"input"
96-
"localrule"
97-
"log"
98-
"message"
99-
"name"
100-
"notebook"
101-
"output"
102-
"params"
103-
"priority"
104-
"resources"
105-
"run"
106-
"script"
107-
"shadow"
108-
"shell"
109-
"singularity"
110-
"threads"
111-
"version"
112-
"wildcard_constraints"
113-
"wrapper"
114-
;; Keys for subworkflow blocks
115-
"configfile"
116-
"snakefile"
117-
"workdir")
118-
symbol-end))
119-
(sm-command . ,(rx symbol-start
120-
(or "configfile"
121-
"container"
122-
"containerized"
123-
"envvars"
124-
"include"
125-
"localrules"
126-
"onerror"
127-
"onsuccess"
128-
"report"
129-
"ruleorder"
130-
"singularity"
131-
"wildcard_constraints"
132-
"workdir")
133-
symbol-end))
134-
(sm-builtin . ,(rx symbol-start
135-
(or "ancient"
136-
"checkpoints"
137-
"directory"
138-
"dynamic"
139-
"expand"
140-
"input"
141-
"multiext"
142-
"output"
143-
"params"
144-
"pipe"
145-
"protected"
146-
"report"
147-
"shell"
148-
"temp"
149-
"touch"
150-
"unpack"
151-
"wildcards")
152-
symbol-end)))
153-
"Snakemake-specific sexps for `snakemake-rx'.")
154-
155-
(defmacro snakemake-rx (&rest regexps)
156-
"Specialized `rx' for Snakemake mode."
157-
;; Modified from `python-rx'.
158-
(let ((rx-constituents (append snakemake-rx-constituents rx-constituents)))
159-
(cond ((null regexps)
160-
(error "No regexp"))
161-
((cdr regexps)
162-
(rx-to-string `(and ,@regexps) t))
163-
(t
164-
(rx-to-string (car regexps) t))))))
76+
(defmacro snakemake-rx (&rest regexps)
77+
"Specialized `rx' for Snakemake mode."
78+
;; Modified from `python-rx'.
79+
`(rx-let ((named-rule (and (group
80+
symbol-start
81+
(or "checkpoint" "module" "rule" "subworkflow"))
82+
" "
83+
(group (one-or-more
84+
(or (syntax word) (syntax symbol))))))
85+
(anon-rule (and symbol-start "rule"))
86+
(field-key (and symbol-start
87+
(or "benchmark"
88+
"cache"
89+
"conda"
90+
"container"
91+
"cwl"
92+
"default_target"
93+
"envmodules"
94+
"group"
95+
"handover"
96+
"input"
97+
"localrule"
98+
"log"
99+
"message"
100+
"name"
101+
"notebook"
102+
"output"
103+
"params"
104+
"priority"
105+
"resources"
106+
"run"
107+
"script"
108+
"shadow"
109+
"shell"
110+
"singularity"
111+
"threads"
112+
"version"
113+
"wildcard_constraints"
114+
"wrapper"
115+
;; Keys for subworkflow blocks
116+
"configfile"
117+
"snakefile"
118+
"workdir")
119+
symbol-end))
120+
(sm-command (and symbol-start
121+
(or "configfile"
122+
"container"
123+
"containerized"
124+
"envvars"
125+
"include"
126+
"localrules"
127+
"onerror"
128+
"onsuccess"
129+
"report"
130+
"ruleorder"
131+
"singularity"
132+
"wildcard_constraints"
133+
"workdir")
134+
symbol-end))
135+
(sm-builtin (and symbol-start
136+
(or "ancient"
137+
"checkpoints"
138+
"directory"
139+
"dynamic"
140+
"expand"
141+
"input"
142+
"multiext"
143+
"output"
144+
"params"
145+
"pipe"
146+
"protected"
147+
"report"
148+
"shell"
149+
"temp"
150+
"touch"
151+
"unpack"
152+
"wildcards")
153+
symbol-end)))
154+
(rx ,@regexps)))
165155

166156
(defconst snakemake-rule-or-subworkflow-re
167157
(snakemake-rx line-start (zero-or-more space)

0 commit comments

Comments
 (0)