diff options
author | Kyle Meyer <kyle@kyleam.com> | 2016-04-16 11:21:17 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2016-04-17 12:38:07 -0400 |
commit | ab40d5ac70e99689ffec68b1e39d99c1c7b4a654 (patch) | |
tree | 0c3b992a48987096539e0d2ab7ec2e533eb87a3a /snakemake.el | |
parent | 6b538a9f5e2d9e9a138704b0a702ffe1237dc57b (diff) | |
download | snakemake-mode-ab40d5ac70e99689ffec68b1e39d99c1c7b4a654.tar.gz |
Add snakemake-graph command
Re: #9
Diffstat (limited to 'snakemake.el')
-rw-r--r-- | snakemake.el | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/snakemake.el b/snakemake.el index 20ec2cd..f6d769b 100644 --- a/snakemake.el +++ b/snakemake.el @@ -350,6 +350,32 @@ targets." (snakemake-all-rules)) " ")) +;;;###autoload +(defun snakemake-graph (rules &optional rule-graph) + "Display graph for DAG of RULES. + +The graph will be processed by `snakemake-dot-program' and +displayed with `image-mode'. + +If prefix argument RULE-GRAPH is non-nil, pass --rulegraph +instead of --dag to snakemake. + +$ snakemake --{dag,rulegraph} -- RULES | display" + (interactive (list (or (snakemake-file-targets-at-point 'check) + (snakemake-rule-at-point 'target) + (snakemake-read-rule 'targets)) + current-prefix-arg)) + (let ((dir (snakemake-snakefile-directory))) + (with-current-buffer (get-buffer-create "*Snakemake graph*") + (setq default-directory dir) + (let ((inhibit-read-only t)) + (erase-buffer) + (apply #'call-process snakemake-program nil t nil + (if rule-graph "--rulegraph" "--dag") + (if (listp rules) rules (list rules)))) + (image-mode) + (pop-to-buffer (current-buffer))))) + ;;; Compilation commands |