aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-05-13 12:03:05 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-05-13 12:03:05 -0700
commit52ab4ac76d8a40323b6479f12461cd2b55bdec19 (patch)
tree9c58cd078805fcc740e0dd50b33b56a46306ef86
parenta966ad01b50aa44c19cbe16c5496c8d0055c1c66 (diff)
downloadhaskell-tab-indent-52ab4ac76d8a40323b6479f12461cd2b55bdec19.tar.gz
safer reindenting of 'where' on previous line
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--NEWS.md4
-rw-r--r--haskell-tab-indent.el6
2 files changed, 7 insertions, 3 deletions
diff --git a/NEWS.md b/NEWS.md
index 40b9013..8693d81 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -15,8 +15,8 @@
- 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, try to fix the indentation of the line containing
- 'where' if it's not correct.
+ When doing so, ensure that the 'where' on the previous line is
+ preceded by two spaces.
- When one of the above cases does not apply, default to indenting to
the same level of the previous line, unless the user explicitly
diff --git a/haskell-tab-indent.el b/haskell-tab-indent.el
index 8ba205e..9515d2b 100644
--- a/haskell-tab-indent.el
+++ b/haskell-tab-indent.el
@@ -94,7 +94,11 @@
;; more
(prev-line-where
;; also ensure indentation of the 'where' is correct
- (save-excursion (forward-line -1) (haskell-tab-indent))
+ (save-excursion
+ (beginning-of-line 0)
+ (skip-chars-forward "\t")
+ (unless (looking-at " where$")
+ (insert " ")))
(tabs (1+ prev-line-tabs)))
;; if the user explicitly requested an indent
;; change, cycle through the plausible indents