aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-05-13 11:44:50 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-05-13 11:44:50 -0700
commit258f29c9b11d040bac85bd43be4ac858146d0bcf (patch)
treece971222ae49dd830c1828a60d8b976b056fde9d
parent88fe919d2b6af8b81c25fdad291c2dd062dff7f4 (diff)
downloadhaskell-tab-indent-258f29c9b11d040bac85bd43be4ac858146d0bcf.tar.gz
fix the indentation of line containing 'where' if needed
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--NEWS.md3
-rw-r--r--haskell-tab-indent.el8
2 files changed, 10 insertions, 1 deletions
diff --git a/NEWS.md b/NEWS.md
index d46fcd5..aeadaae 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -15,6 +15,9 @@
- Always indent the first line of the contents of a where clause to
one plus the level of the line containing 'where'.
+ When doing so, fix the indentation of the line containing 'where' if
+ it's not correct.
+
- When one of the above cases does not apply, default to indenting to
the same level of the previous line, unless the user explicitly
invoked `indent-for-tab-command' (e.g. by hitting the tab key), in
diff --git a/haskell-tab-indent.el b/haskell-tab-indent.el
index 15686cb..9680749 100644
--- a/haskell-tab-indent.el
+++ b/haskell-tab-indent.el
@@ -92,7 +92,13 @@
(prev-line-decl prev-line-tabs)
;; if the previous line was the beginning of a where
;; clause, indent should be exactly one more
- (prev-line-where (1+ prev-line-tabs))
+ (prev-line-where
+ ;; also ensure indentation of the 'where' is
+ ;; correct
+ (save-excursion
+ (forward-line -1)
+ (haskell-tab-indent))
+ (1+ prev-line-tabs))
;; if the user explicitly requested an indent
;; change, cycle through the plausible indents
((eq this-command 'indent-for-tab-command)