branch: elpa/scala-mode commit 338ff7344ad5dd4130a91a06d87180603d5d1272 Author: Heikki Vesalainen <heikkivesalai...@yahoo.com> Commit: Heikki Vesalainen <heikkivesalai...@yahoo.com>
Changed the indent defaults, closes #19 --- README.md | 83 ++++++++++++++++++++++++++-------------------------- scala-mode-indent.el | 6 ++-- 2 files changed, 45 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 080456f..f44a388 100644 --- a/README.md +++ b/README.md @@ -97,21 +97,8 @@ line will toggle between the modes. ### Value expressions (scala-indent:indent-value-expression) -When this variable is set to *t* (default), blocks in value -expressions will be indented one extra step to make the *val*, *var* -or *def* stand out. For example: - -``` -val x = try { - some() - } catch { - case e => other - } finally { - clean-up() - } -``` - -When the variable is set to *nil*, the same will indent as: +When this variable is set to *nil* (default), body of a value +expressions will be indented in the traditional way. ``` val x = try { @@ -123,67 +110,81 @@ val x = try { } ``` +However, when the variable is set to *t*, the body will be indented +one extra step to make the *val*, *var* or *def* stand out. For +example: + +``` +val x = try { + some() + } catch { + case e => other + } finally { + clean-up() + } +``` + ### Parameter lists (scala-indent:align-parameters) -When this variable is set to *t* (default), parameters and run-on -lines in parameter lists will always align under and acording to the +When this variable is set to *nil* (default), parameters and run-on +lines in parameter lists will not align under or acording to the first parameter. ``` val y = List( "Alpha", "Bravo", - "Charlie" ) + "Charlie" ) val x = equals(List(1,2,3) map (x => - x + 1)) + x + 1)) ``` -When the variable is set to *nil*, the same will be indented as: +When the variable is set to *t*, the same will be indented as: ``` val y = List( "Alpha", "Bravo", - "Charlie" ) + "Charlie" ) val x = equals(List(1,2,3) map (x => - x + 1)) + x + 1)) ``` ### Expresison forms: if, for, try (scala-indent:align-forms) -When this variable is set to *t* (default), *if*, *for* and *try* -forms are aligned. +When this variable is set to *nil* (default), *if*, *for* and *try* +forms are not aligned specially. ``` val x = if (kala) - foo - else if (koira) - bar - else - zot + foo +else if (koira) + bar +else + zot val x = try "1".toInt - catch { case e => 0} - finally { println("hello") } +catch { case e => 0} +finally { println("hello") } val xs = for (i <- 1 to 10) - yield i +yield i ``` -When the variable is set to *nil*, the same will be indented as: +When the variable is set to *t*, the same will be indented as: ``` val x = if (kala) - foo - else if (koira) - bar - else - zot + foo + else if (koira) + bar + else + zot val x = try "1".toInt - catch { case e => 0} - finally { println("hello") } + catch { case e => 0} + finally { println("hello") } val xs = for (i <- 1 to 10) - yield i + yield i ``` ## Indenting multi-line comments diff --git a/scala-mode-indent.el b/scala-mode-indent.el index 1e656e1..cf953c0 100644 --- a/scala-mode-indent.el +++ b/scala-mode-indent.el @@ -13,7 +13,7 @@ indentation will be one or two steps depending on context." :type 'integer :group 'scala) -(defcustom scala-indent:indent-value-expression t +(defcustom scala-indent:indent-value-expression nil "Whether or not to indent multi-line value expressions, with one extra step. When true, indenting will be @@ -38,7 +38,7 @@ val x = try { :type 'boolean :group 'scala) -(defcustom scala-indent:align-parameters t +(defcustom scala-indent:align-parameters nil "Whether or not to indent parameter lists so that next parameter lines always align under the first parameter. When non-nil, indentation will be @@ -62,7 +62,7 @@ val x = foo(1, List(1, 2, 3) map (i => :type 'boolean :group 'scala) -(defcustom scala-indent:align-forms t +(defcustom scala-indent:align-forms nil "Whether or not to align 'else', 'yield', 'catch', 'finally' below their respective expression start. When non-nil, identing will be