branch: elpa/yaml-mode commit 85d5c630c1b1a2226d657ee01c4e60d039e04474 Author: Antal K <anta...@gmail.com> Commit: Antal K <anta...@gmail.com>
allow dash-newline to start a sequence --- test-files/test-dash-newline-starts-sequence.yaml | 35 +++++++++++++++++++++++ yaml-mode.el | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/test-files/test-dash-newline-starts-sequence.yaml b/test-files/test-dash-newline-starts-sequence.yaml new file mode 100644 index 0000000..c8de74a --- /dev/null +++ b/test-files/test-dash-newline-starts-sequence.yaml @@ -0,0 +1,35 @@ +# +# Old behaviour (version 0.0.12) +# +# (1) Move to cursor to the beginning of the line containing 'aaa' +# (2) Press TAB +# (3) The line should be indented now. +# Problem: the line is not indented. +# +# Note: in the line containing the dash ('-') there is no space character +# after the dash, so it is not recognized as start of the sequence entry +# by +# +# (defconst yaml-nested-sequence-re +# (concat "^\\(?: *- +\\)+" +# "\\(?:" yaml-bare-scalar-re " *:\\(?: +.*\\)?\\)?$") +# "Regexp matching a line containing one or more nested YAML sequences.") +# +# Proposed change: +# +# Change yaml-bare-scalar-re to +# +# (defconst yaml-nested-sequence-re +# (concat "^\\(?:\\(?: *- +\\)+\\|\\(:?-$\\)\\)" +# "\\(?:" yaml-bare-scalar-re " *:\\(?: +.*\\)?\\)?$") +# "Regexp matching a line containing one or more nested YAML sequences.") +# +# The added alternative \\(:?-$\\) now recognizes the dash-newline sequence. +# +# New behaviour: +# +# (1) Pressing TAB on the line containing 'aaa' now indents the line. +# (2) Pressing TAB again unindents the line. +# +- +aaa diff --git a/yaml-mode.el b/yaml-mode.el index 15f3872..c7c8966 100644 --- a/yaml-mode.el +++ b/yaml-mode.el @@ -162,7 +162,7 @@ that key is pressed to begin a block literal." "Regexp matching a line beginning a YAML block literal.") (defconst yaml-nested-sequence-re - (concat "^\\(?: *- +\\)+" + (concat "^\\(?:\\(?: *- +\\)+\\|\\(:?-$\\)\\)" "\\(?:" yaml-bare-scalar-re " *:\\(?: +.*\\)?\\)?$") "Regexp matching a line containing one or more nested YAML sequences.")