Skip to content

Implement haskell-comment-function. #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2015
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