branch: elpa/scala-mode commit 6257e3bd9da2755318cddf233bf51834be7b92f8 Author: Heikki Vesalainen <heikkivesalai...@yahoo.com> Commit: Heikki Vesalainen <heikkivesalai...@yahoo.com>
Renamed bad-equals to indent-value-expression. Added info to README.md --- README.md | 29 +++++++++++++++++++++++++++++ scala-mode-indent.el | 26 +++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 38692bc..21f7839 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ are having trouble with colors, try setting the customization variable ## Indenting modes +### Run-on lines (scala-indent:default-run-on-strategy) + The indenting engine has three modes for handling run-on lines. The 'reluctant' (default) mode is geared toward a general style of coding and the 'eager' for strictly functional style. A third mode called @@ -74,6 +76,33 @@ val y = foo("bar") However, in all three modes pressing tab repeatedly on a line will toggle between the modes. +### Value expressions (scala-indent:indent-value-expression) + +When 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: + +``` +val x = try { + some() +} catch { + case e => other +} finally { + clean-up() +} +``` + ## Motion Basic emacs motion will work as expected. The forward-sexp and diff --git a/scala-mode-indent.el b/scala-mode-indent.el index 54fb86e..03ae083 100644 --- a/scala-mode-indent.el +++ b/scala-mode-indent.el @@ -13,8 +13,28 @@ indentation will be one or two steps depending on context." :type 'integer :group 'scala) -(defcustom scala-indent:pad-equals t - "Whether or not to indent an extral level directly after =." +(defcustom scala-indent:indent-value-expression t + "Whether or not to indent multi-line value expressions, with +one extra step. When true, indenting will be + +val x = try { + some() + } catch { + case e => other + } finally { + clean-up() + } + +When nil, the same will indent as + +val x = try { + some() +} catch { + case e => other +} finally { + clean-up() +} +" :type 'boolean :group 'scala) @@ -472,7 +492,7 @@ anchor for calculating block indent for current point (or point ;;; calculate a lead that is used for all steps. The lead is one ;;; indent step if there is a '=' between anchor and start, ;;; otherwise 0. - ((lead (if (and scala-indent:pad-equals (ignore-errors + ((lead (if (and scala-indent:indent-value-expression (ignore-errors (save-excursion (let ((block-beg (nth 1 (syntax-ppss start)))) (goto-char anchor)