Function: haskell-fill-paragraph
haskell-fill-paragraph is a natively compiled function defined in
haskell-mode.el.
Signature
(haskell-fill-paragraph JUSTIFY)
Source Code
;; Defined in /nix/store/9lz2mhw95f9fqxr9mnq46k3f6qz3aq83-emacs-packages-deps/share/emacs/site-lisp/elpa/haskell-mode-20260904.1042/haskell-mode.el
(defun haskell-fill-paragraph (justify)
(save-excursion
;; Fill paragraph should only work in comments.
;; The -- comments are handled properly by default
;; The {- -} comments need some extra love.
(let* ((syntax-values (syntax-ppss))
(comment-num (nth 4 syntax-values)))
(cond
((eq t comment-num)
;; standard fill works wonders inside a non-nested comment
(fill-comment-paragraph justify))
((integerp comment-num)
;; we are in a nested comment. lets narrow to comment content
;; and use plain paragraph fill for that
(let* ((comment-start-point (nth 8 syntax-values))
(comment-end-point
(save-excursion
(goto-char comment-start-point)
(forward-sexp)
;; Find end of any comment even if forward-sexp
;; fails to find the right braces.
(backward-char 3)
(re-search-forward "[ \t]?-}" nil t)
(match-beginning 0)))
(fill-start (+ 2 comment-start-point))
(fill-end comment-end-point)
(fill-paragraph-handle-comment nil))
(save-restriction
(narrow-to-region fill-start fill-end)
(fill-paragraph justify)
;; If no filling happens, whatever called us should not
;; continue with standard text filling, so return t
t)))
((eolp)
;; do nothing outside of a comment
t)
(t
;; go to end of line and try again
(end-of-line)
(haskell-fill-paragraph justify))))))