Skip to content

Commit 81487e9

Browse files
committed
Merge pull request #431 from gracjan/pr-haskell-comment-function
Implement haskell-comment-function.
2 parents ad362a5 + d7f5528 commit 81487e9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

haskell-simple-indent.el

+16
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,21 @@ point beyond the current column, position given by
183183
(haskell-simple-indent-newline-same-col)
184184
(insert (make-string haskell-indent-spaces ? )))
185185

186+
(defun haskell-simple-indent-comment-indent-function ()
187+
"Haskell version of `comment-indent-function'."
188+
;; This is required when filladapt is turned off. Without it, when
189+
;; filladapt is not used, comments which start in column zero
190+
;; cascade one character to the right
191+
(save-excursion
192+
(beginning-of-line)
193+
(let ((eol (line-end-position)))
194+
(and comment-start-skip
195+
(re-search-forward comment-start-skip eol t)
196+
(setq eol (match-beginning 0)))
197+
(goto-char eol)
198+
(skip-chars-backward " \t")
199+
(max comment-column (+ (current-column) (if (bolp) 0 1))))))
200+
186201
;;;###autoload
187202
(define-minor-mode haskell-simple-indent-mode
188203
"Simple Haskell indentation mode that uses simple heuristic.
@@ -197,6 +212,7 @@ Runs `haskell-simple-indent-hook' on activation."
197212
:lighter " Ind"
198213
:group 'haskell-simple-indent
199214
:keymap '(([backtab] . haskell-simple-indent-backtab))
215+
(set (make-local-variable 'comment-indent-function) #'haskell-simple-indent-comment-indent-function)
200216
(kill-local-variable 'indent-line-function)
201217
(when haskell-simple-indent-mode
202218
(set (make-local-variable 'indent-line-function) 'haskell-simple-indent)

0 commit comments

Comments
 (0)