summaryrefslogtreecommitdiff
path: root/snakemake.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-09-05 23:49:22 -0400
committerKyle Meyer <kyle@kyleam.com>2016-09-13 23:31:27 -0400
commit2bceb7f266f71cd85f9b328de02797eb457da17c (patch)
tree3ccd47f8ff8a35f16f297e5243e03fe696d899ee /snakemake.el
parenta28ff63f4c3a6492dea38c028e47bb6431ab4c84 (diff)
downloadsnakemake-mode-2bceb7f266f71cd85f9b328de02797eb457da17c.tar.gz
snakemake-check-target: Recognize protected items
With 33a7c90 (snakemake-check-target: Adjust for upstream output, 2016-09-01), write-protected targets were no longer considered valid targets.
Diffstat (limited to 'snakemake.el')
-rw-r--r--snakemake.el17
1 files changed, 13 insertions, 4 deletions
diff --git a/snakemake.el b/snakemake.el
index 9a93f9e..9ec7b42 100644
--- a/snakemake.el
+++ b/snakemake.el
@@ -258,15 +258,24 @@ The file list is determined by the output of
(regexp-opt (list "MissingRuleException"
"RuleException")))
+(defconst snakemake-valid-target-re "ProtectedOutputException"
+ "Regular expression indicating valid target.
+If this matches, the target will be considered valid even if the
+exit status is non-zero.")
+
(defun snakemake-check-target (target &optional directory)
"Return non-nil if TARGET is a valid target for DIRECTORY's Snakefile."
(snakemake-with-cache directory (target)
(with-temp-buffer
- (when (= 0 (snakemake-insert-output "--quiet" "--dryrun" target))
+ (let ((ex-code (snakemake-insert-output "--quiet" "--dryrun" target)))
(goto-char (point-min))
- ;; Lean towards misclassifying targets as valid rather than
- ;; silently dropping valid targets as invalid.
- (not (re-search-forward snakemake-invalid-target-re nil t))))))
+ (cond
+ ((re-search-forward snakemake-valid-target-re nil t))
+ ((and (= ex-code 0)
+ ;; Lean towards misclassifying targets as valid rather
+ ;; than silently dropping valid targets as invalid.
+ (not (re-search-forward snakemake-invalid-target-re
+ nil t)))))))))
(declare-function org-element-context "org-element")
(declare-function org-element-property "org-element")