From 38e5bfec014771cab73aac4a95d22ca93160b821 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Wed, 8 Apr 2015 22:30:58 -0400 Subject: Use rx to make regular expressions --- snakemake-mode.el | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'snakemake-mode.el') diff --git a/snakemake-mode.el b/snakemake-mode.el index df4103f..c445a0b 100644 --- a/snakemake-mode.el +++ b/snakemake-mode.el @@ -81,7 +81,10 @@ ;;; Regexp (defconst snakemake-rule-or-subworkflow-re - "\\(rule\\|subworkflow\\) \\([a-zA-Z0-9_]+\\):" + (rx (group symbol-start (or "rule" "subworkflow")) + " " + (one-or-more (or (syntax word) (syntax symbol))) + ":") "Regexp matching a rule or subworkflow.") (defconst snakemake-rule-or-subworkflow-line-re @@ -89,14 +92,19 @@ "Regexp matching a rule or subworkflow at start of line.") (defconst snakemake-toplevel-command-re - (concat "^\\(include\\|workdir\\|ruleorder\\|configfile" - "\\|onsuccess\\|onerror\\):") + (rx line-start + (group (or "include" "workdir" "ruleorder" "configfile" + "onsuccess" "onerror")) + ":" (zero-or-more space) + line-end) "Regexp matching other toplevel commands aside from 'rule'.") (defconst snakemake-field-key-re - (concat "\\(input\\|output\\|shell\\|run\\|workdir\\|priority" - "\\|message\\|threads\\|version\\|resources\\|params" - "\\|log\\|benchmark\\|snakefile\\):") + (rx (group symbol-start + (or "input" "output" "shell" "run" "workdir" "priority" + "message" "threads" "version" "resources" "params" + "log" "benchmark" "snakefile")) + ":") "Regexp matching a rule or subworkflow field key.") (defconst snakemake-field-key-indented-re @@ -104,7 +112,9 @@ "Regexp matching a field key, including indentation.") (defconst snakemake-builtin-function-re - "\\(expand\\|shell\\|protected\\|temp\\|dynamic\\)(" + (rx (group symbol-start + (or "expand" "shell" "protected" "temp" "dynamic")) + "(") "Regexp matching a call to a builtin Snakemake function.") -- cgit v1.2.3