From 52ab4ac76d8a40323b6479f12461cd2b55bdec19 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 13 May 2020 12:03:05 -0700 Subject: safer reindenting of 'where' on previous line Signed-off-by: Sean Whitton --- NEWS.md | 4 ++-- haskell-tab-indent.el | 6 +++++- 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 -- cgit v1.2.3