Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions haskell-simple-indent.el
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,21 @@ column, `tab-to-tab-stop' is done instead."
(haskell-simple-indent-newline-same-col)
(insert (make-string haskell-indent-spaces ? )))

(defun haskell-simple-indent-comment-indent-function ()
"Haskell version of `comment-indent-function'."
;; This is required when filladapt is turned off. Without it, when
;; filladapt is not used, comments which start in column zero
;; cascade one character to the right
(save-excursion
(beginning-of-line)
(let ((eol (line-end-position)))
(and comment-start-skip
(re-search-forward comment-start-skip eol t)
(setq eol (match-beginning 0)))
(goto-char eol)
(skip-chars-backward " \t")
(max comment-column (+ (current-column) (if (bolp) 0 1))))))

;;;###autoload
(define-minor-mode haskell-simple-indent-mode
"Simple Haskell indentation mode that uses simple heuristic.
Expand All @@ -189,6 +204,7 @@ Runs `haskell-simple-indent-hook' on activation."
:lighter " Ind"
:group 'haskell-simple-indent
:keymap '(([backtab] . haskell-simple-indent-backtab))
(set (make-local-variable 'comment-indent-function) #'haskell-simple-indent-comment-indent-function)
(kill-local-variable 'indent-line-function)
(when haskell-simple-indent-mode
(set (make-local-variable 'indent-line-function) 'haskell-simple-indent)
Expand Down