aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-05-13 10:59:01 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-05-13 10:59:01 -0700
commitefbe6610ab6ef3cebd0708f5c34b72c346b0228d (patch)
tree0cf27f183927a5a25677d591091ff2d9dbb00611
parent7316a575ee5c628809fe5779a7bde9dc9bbb2aab (diff)
downloadhaskell-tab-indent-efbe6610ab6ef3cebd0708f5c34b72c346b0228d.tar.gz
simplify lining up declarations and definitions
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--haskell-tab-indent.el19
1 files changed, 5 insertions, 14 deletions
diff --git a/haskell-tab-indent.el b/haskell-tab-indent.el
index 678cffa..e6c58a4 100644
--- a/haskell-tab-indent.el
+++ b/haskell-tab-indent.el
@@ -59,13 +59,7 @@
(length (seq-filter (lambda (c) (equal c ?\t))
(buffer-substring
(line-beginning-position)
- (point))))))
- (line-first-word () (save-excursion
- (back-to-indentation)
- (let ((beg (point)))
- (while (not (looking-at "[[:space:]]"))
- (forward-char))
- (buffer-substring-no-properties beg (point))))))
+ (point)))))))
(defun haskell-tab-indent ()
"Auto indentation on TAB for `haskell-tab-indent-mode'."
(interactive)
@@ -75,10 +69,6 @@
(cl-loop do (beginning-of-line 0)
while (looking-at "[[:space:]]*$"))
(count-line-tabs)))
- (this-first-word (line-first-word))
- (prev-first-word (save-excursion
- (beginning-of-line 0)
- (line-first-word)))
;; determine whether previous line is a declaration
(prev-line-decl
(save-excursion
@@ -88,9 +78,10 @@
(back-to-indentation)
(if (looking-at "where$")
(setf (buffer-substring (line-beginning-position) (point)) " ")
- ;; attempt to line up declarations and definitions
- (if (and prev-line-decl
- (string= this-first-word prev-first-word))
+ ;; if the previous line is a declaration, then this line
+ ;; should be either empty, or at the same indent level as
+ ;; that declaration
+ (if prev-line-decl
(setf (buffer-substring (line-beginning-position) (point))
(make-string prev-line-tabs ?\t))
;; check for special case of being called by