aboutsummaryrefslogtreecommitdiff
path: root/snakemake-mode.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2015-03-05 23:01:52 -0500
committerKyle Meyer <kyle@kyleam.com>2015-03-05 23:01:52 -0500
commitbdbb9c95d401b62d01fa80c04265bcd27658488a (patch)
tree5b507b1ba74689d3749f1ef30088ea61a32d01b4 /snakemake-mode.el
parent81a564f0ae6891b73e17a1ae2ef25a13a552e74c (diff)
downloadsnakemake-mode-bdbb9c95d401b62d01fa80c04265bcd27658488a.tar.gz
Indent field values that start on their own line
Previously, indentation was handled only for the first line following a run value. Extend this to support any field value that starts on the line below a field key, since that is valid syntax.
Diffstat (limited to 'snakemake-mode.el')
-rw-r--r--snakemake-mode.el26
1 files changed, 14 insertions, 12 deletions
diff --git a/snakemake-mode.el b/snakemake-mode.el
index 358db22..d8914e2 100644
--- a/snakemake-mode.el
+++ b/snakemake-mode.el
@@ -62,8 +62,8 @@
:group 'snakemake
:type 'integer)
-(defcustom snakemake-indent-run-offset 2
- "Additional offset for 'run' field value."
+(defcustom snakemake-indent-value-offset 4
+ "Offset for field values that the line below the field key."
:group 'snakemake
:type 'integer)
@@ -132,12 +132,14 @@ rule blocks (or on a blank line directly below), call
Indent the line to `snakemake-indent-field-offset'.
-- Below a 'run' subkey
+- On first line below a naked field key.
- Indent the first line below 'run'
- `snakemake-indent-field-offset' plus
- `snakemake-indent-run-offset'. Indent other lines with
- `python-indent-line-function'.
+ Indent the line with `snakemake-indent-field-offset' plus
+ `snakemake-indent-value-offset'.
+
+- On any 'run' field value line except for the first value line.
+
+ Indent with `python-indent-line-function'.
- Otherwise
@@ -153,10 +155,10 @@ rule blocks (or on a blank line directly below), call
((looking-at-p (concat "^[ \t]*" snakemake-field-key-re))
(delete-horizontal-space)
(indent-to snakemake-indent-field-offset))
- ((snakemake-run-field-first-line-p)
+ ((snakemake-below-naked-field-p)
(delete-horizontal-space)
(indent-to (+ snakemake-indent-field-offset
- snakemake-indent-run-offset)))
+ snakemake-indent-value-offset)))
((snakemake-run-field-line-p)
(python-indent-line-function))
((< start-indent snakemake-indent-field-offset)
@@ -182,12 +184,12 @@ rule blocks (or on a blank line directly below), call
(and (re-search-backward snakemake-rule-or-subworkflow-re nil t)
(not (re-search-forward "^ *$" start t))))))
-(defun snakemake-run-field-first-line-p ()
- "Return non-nil if point is on the first line below a run field key."
+(defun snakemake-below-naked-field-p ()
+ "Return non-nil if point is on first line below a naked field key."
(save-excursion
(forward-line -1)
(beginning-of-line)
- (looking-at-p "^[ \t]+run:")))
+ (looking-at-p (concat snakemake-field-key-indented-re " *$"))))
(defun snakemake-run-field-line-p ()
"Return non-nil if point is on any line below a run field key.