Function: fill-region-as-paragraph-semlf
fill-region-as-paragraph-semlf is an interactive and byte-compiled
function defined in fill.el.gz.
Signature
(fill-region-as-paragraph-semlf FROM TO &optional JUSTIFY NOSQUEEZE SQUEEZE-AFTER)
Documentation
Fill the region using semantic linefeeds as if it were a single paragraph.
This command removes any paragraph breaks in the region and extra
newlines at the end, and fills lines within the region. Text is
refilled putting a newline character after each sentence, calling
forward-sentence to find the ends of sentences. If
sentence-end-double-space is non-nil, period followed by one space is
not the end of a sentence.
If JUSTIFY is non-nil (interactively, with prefix argument), justify as
well. If NOSQUEEZE is non-nil, do not to make spaces between words
canonical before filling. SQUEEZE-AFTER, if non-nil, should be a buffer
position; it means canonicalize spaces only starting from that position.
See canonically-space-region for the meaning of canonicalization of
spaces. The variable fill-column controls the width for filling.
Return the fill-prefix used for filling.
This function can be assigned to fill-region-as-paragraph-function to
override how functions like fill-paragraph and fill-region fill
text.
For more details about semantic linefeeds, see URL https://sembr.org/ and URL https://rhodesmill.org/brandon/2012/one-sentence-per-line/.
Probably introduced at or before Emacs version 31.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/fill.el.gz
(defun fill-region-as-paragraph-semlf (from to &optional justify
nosqueeze squeeze-after)
"Fill the region using semantic linefeeds as if it were a single paragraph.
This command removes any paragraph breaks in the region and extra
newlines at the end, and fills lines within the region. Text is
refilled putting a newline character after each sentence, calling
`forward-sentence' to find the ends of sentences. If
`sentence-end-double-space' is non-nil, period followed by one space is
not the end of a sentence.
If JUSTIFY is non-nil (interactively, with prefix argument), justify as
well. If NOSQUEEZE is non-nil, do not to make spaces between words
canonical before filling. SQUEEZE-AFTER, if non-nil, should be a buffer
position; it means canonicalize spaces only starting from that position.
See `canonically-space-region' for the meaning of canonicalization of
spaces. The variable `fill-column' controls the width for filling.
Return the `fill-prefix' used for filling.
This function can be assigned to `fill-region-as-paragraph-function' to
override how functions like `fill-paragraph' and `fill-region' fill
text.
For more details about semantic linefeeds, see URL `https://sembr.org/'
and URL `https://rhodesmill.org/brandon/2012/one-sentence-per-line/'."
(interactive (progn
(barf-if-buffer-read-only)
(list (region-beginning)
(region-end)
(if current-prefix-arg 'full))))
(let ((from (min from to))
(to (copy-marker (max from to) t))
pfx)
(goto-char from)
(let ((fill-column (* 2 (point-max)))) ; Wide characters span up to two columns.
(setq pfx (or (save-excursion
(fill-region-as-paragraph-default (point)
to
nil
nosqueeze
squeeze-after))
"")))
(while (< (point) to)
(let ((fill-to (copy-marker
(min to
(save-excursion
(forward-sentence)
(point)))
t))
(fill-prefix pfx))
(fill-region-as-paragraph-default (point)
fill-to
justify
t)
(goto-char fill-to))
(when (and (> (point) (line-beginning-position))
(< (point) (line-end-position))
(< (point) to))
(delete-horizontal-space)
(insert "\n")
(insert pfx)))
pfx))