diff options
author | Kyle Meyer <kyle@kyleam.com> | 2016-02-28 12:28:05 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2016-02-28 12:29:51 -0500 |
commit | c44f74a155d27cb558e488513dbf21fccce5a6a3 (patch) | |
tree | 29827ed76f17045c7196c910c4fc138a141d51ee | |
parent | ddf1ba288005848d64cf97354db5a67598b4a029 (diff) | |
download | snakemake-mode-c44f74a155d27cb558e488513dbf21fccce5a6a3.tar.gz |
Fix rule recognition at beginning of buffer
-rw-r--r-- | snakemake-mode.el | 8 | ||||
-rw-r--r-- | snakemake-test.el | 7 |
2 files changed, 12 insertions, 3 deletions
diff --git a/snakemake-mode.el b/snakemake-mode.el index 2e40b7b..368c4c3 100644 --- a/snakemake-mode.el +++ b/snakemake-mode.el @@ -229,9 +229,11 @@ Indent according the the first case below that is true. (when (funcall blank-p) (forward-line -1)) (catch 'in-block - (while (not (or (bobp) (funcall blank-p))) - (when (looking-at-p snakemake-rule-or-subworkflow-re) - (throw 'in-block t)) + (while (not (funcall blank-p)) + (cond ((looking-at-p snakemake-rule-or-subworkflow-re) + (throw 'in-block t)) + ((bobp) + (throw 'in-block nil))) (forward-line -1)))))) (defun snakemake-below-naked-field-p () diff --git a/snakemake-test.el b/snakemake-test.el index 880d7d5..8ebb3ff 100644 --- a/snakemake-test.el +++ b/snakemake-test.el @@ -522,6 +522,13 @@ rule abc: output: 'file'" (should-not (snakemake-in-rule-or-subworkflow-block-p))) + ;; At beginning of buffer + (snakemake-with-temp-text + "\ +rule abc: + output: 'file'<point>" + (should (snakemake-in-rule-or-subworkflow-block-p))) + ;; Subworkflow (snakemake-with-temp-text " |