You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
f x = x {- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed risus ipsum. -}
yields (if the current point is between "Lorem" and "sed"):
f x = x {- Lorem ipsum dolor sit amet, consectetur adipiscing{- elit. Donec sedrisus ipsum.-}
I have developed a replacement for haskell-fill-paragraph which
consistently generates:
f x = x {- Lorem ipsum dolor sit amet, consectetur adipiscingelit. Donec sed risus ipsum. -}
Which, I believe, is a correct behaviour.
The function follows.
(defunhaskell-fill-paragraph (justify)
(save-excursion;; Fill paragraph should only work in comments.;; The -- comments are handled properly by default;; The {- -} comments are handled specially here.
(let* ((syntax-values (syntax-ppss))
(comment-num (nth4 syntax-values)))
(cond
((eqt 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 (nth8 syntax-values))
(comment-end-point
(save-excursion
(goto-char comment-start-point)
(forward-comment1)
(point)))
(paragraph-start-point (save-excursion (backward-paragraph) (point)))
(paragraph-end-point (save-excursion (forward-paragraph) (point))))
;; If a nested comment is broken into several paragraphs, then fill only the current one.
(fill-region (max paragraph-start-point comment-start-point)
(min paragraph-end-point comment-end-point)
justify))
t;; return t so that fill-paragraph does not keep;; going. (This route was successfull regardless the;; output of fill-region)
)
((eolp)
;; do nothing outside of a commentt)
(t;; go to end of line and try again
(end-of-line)
(haskell-fill-paragraph justify))))))
The text was updated successfully, but these errors were encountered:
Calling fill-paragraph on this snippet:
yields (if the current point is between "Lorem" and "sed"):
I have developed a replacement for haskell-fill-paragraph which
consistently generates:
Which, I believe, is a correct behaviour.
The function follows.
The text was updated successfully, but these errors were encountered: