aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2016-04-15 12:42:22 -0400
committerKyle Meyer <kyle@kyleam.com>2016-04-15 12:42:22 -0400
commit66f0d242fa063277713e723d83d051402ff12e1d (patch)
tree245e4e3da1a7ed7a2e7a2f8dd6055cdd9c769741
parent90faba359fe4263c365f33c32e00131a7cf61d53 (diff)
downloadsnakemake-mode-66f0d242fa063277713e723d83d051402ff12e1d.tar.gz
mode: Unset indent-region-function
Don't use python-indent-region for indent-region-function. At first glance, setting indent-region-function to nil (that is, running indent-according-to-mode on each line) seems to indent rule blocks fine, though it will probably fail on more complex "run" values. However, this does mean that python-indent-region is no longer used when indent-region is called with a region that doesn't include a rule block, so it's probably worth adding a snakemake-indent-region function that calls python-indent-region in this case. Re: #8
-rw-r--r--snakemake-mode.el1
-rw-r--r--snakemake-test.el51
2 files changed, 52 insertions, 0 deletions
diff --git a/snakemake-mode.el b/snakemake-mode.el
index dc9fbf8..319a0d8 100644
--- a/snakemake-mode.el
+++ b/snakemake-mode.el
@@ -338,6 +338,7 @@ label."
(set (make-local-variable 'imenu-create-index-function)
#'snakemake-imenu-create-index)
(set (make-local-variable 'indent-line-function) 'snakemake-indent-line)
+ (set (make-local-variable 'indent-region-function) nil)
(set (make-local-variable 'font-lock-defaults)
`(,(append snakemake-font-lock-keywords python-font-lock-keywords))))
diff --git a/snakemake-test.el b/snakemake-test.el
index 6374b0d..eeb2e5f 100644
--- a/snakemake-test.el
+++ b/snakemake-test.el
@@ -469,6 +469,57 @@ rule abc:
(snakemake-indent-line)
(buffer-string)))))
+(ert-deftest snakemake-test/indent-region ()
+ (should
+ (string=
+ "
+rule abc:
+ input: 'infile'
+ output:"
+ (snakemake-with-temp-text
+ "
+<point>rule abc:
+input: 'infile'
+output:"
+ (indent-region (point) (point-max))
+ (buffer-string))))
+ (should
+ (string=
+ "
+rule abc:
+ input:
+ one='one', two='two'
+ output: 'out'
+ run:
+ with open(input.one) as ifh:
+ with open(output.out, 'w') as ofh:
+ ofh.write(ifh.read())"
+ (snakemake-with-temp-text
+ "
+<point>rule abc:
+input:
+one='one', two='two'
+output: 'out'
+run:
+with open(input.one) as ifh:
+with open(output.out, 'w') as ofh:
+ofh.write(ifh.read())"
+ (indent-region (point) (point-max))
+ (buffer-string))))
+ (should
+ (string=
+ "
+x = [1,
+ 2,
+ 3,]"
+ (snakemake-with-temp-text
+ "
+<point>x = [1,
+2,
+3,]"
+ (indent-region (point) (point-max))
+ (buffer-string)))))
+
;;;; Other
(ert-deftest snakemake-test-in-rule-or-subworkflow-block-p ()