Commit 4c06fbee authored by Karl Heuer's avatar Karl Heuer
Browse files

(lisp-fill-paragraph): When filling a comment,

find paragraph bounds by hand, and pass the SQUEEZE-AFTER arg
to fill-region-as-paragraph.
parent c7edd03c
...@@ -740,28 +740,42 @@ and initial semicolons." ...@@ -740,28 +740,42 @@ and initial semicolons."
(fill-paragraph justify) (fill-paragraph justify)
;; Narrow to include only the comment, and then fill the region. ;; Narrow to include only the comment, and then fill the region.
(save-restriction (save-excursion
(beginning-of-line) (save-restriction
(narrow-to-region (beginning-of-line)
;; Find the first line we should include in the region to fill. (narrow-to-region
(save-excursion ;; Find the first line we should include in the region to fill.
(while (and (zerop (forward-line -1)) (save-excursion
(looking-at "^[ \t]*;"))) (while (and (zerop (forward-line -1))
;; We may have gone too far. Go forward again.
(or (looking-at ".*;")
(forward-line 1))
(point))
;; Find the beginning of the first line past the region to fill.
(save-excursion
(while (progn (forward-line 1)
(looking-at "^[ \t]*;"))) (looking-at "^[ \t]*;")))
(point))) ;; We may have gone too far. Go forward again.
(or (looking-at ".*;")
;; Lines with only semicolons on them can be paragraph boundaries. (forward-line 1))
(let ((paragraph-start (concat paragraph-start "\\|[ \t;]*$")) (point))
(paragraph-separate (concat paragraph-start "\\|[ \t;]*$")) ;; Find the beginning of the first line past the region to fill.
(fill-prefix comment-fill-prefix)) (save-excursion
(fill-paragraph justify)))) (while (progn (forward-line 1)
(looking-at "^[ \t]*;")))
(point)))
;; Lines with only semicolons on them can be paragraph boundaries.
(let* ((paragraph-start (concat paragraph-start "\\|[ \t;]*$"))
(paragraph-separate (concat paragraph-start "\\|[ \t;]*$"))
(paragraph-ignore-fill-prefix nil)
(fill-prefix comment-fill-prefix)
(end (progn
(forward-paragraph)
(or (bolp) (newline 1))
(point)))
(beg (progn (backward-paragraph) (point))))
(fill-region-as-paragraph beg end
justify nil
(save-excursion
(goto-char beg)
(if (looking-at fill-prefix)
nil
(re-search-forward comment-start-skip)
(point))))))))
t)) t))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment