Function: fill-delete-newlines
fill-delete-newlines is a byte-compiled function defined in
fill.el.gz.
Signature
(fill-delete-newlines FROM TO JUSTIFY NOSQUEEZE SQUEEZE-AFTER)
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/fill.el.gz
(defun fill-delete-newlines (from to justify nosqueeze squeeze-after)
(goto-char from)
;; Make sure sentences ending at end of line get an extra space.
;; loses on split abbrevs ("Mr.\nSmith")
(let ((eol-double-space-re
(cond
((not colon-double-space) (concat (sentence-end) "$"))
;; Try to add the : inside the `sentence-end' regexp.
((string-match "\\[[^][]*\\(\\.\\)[^][]*\\]" (sentence-end))
(concat (replace-match ".:" nil nil (sentence-end) 1) "$"))
;; Can't find the right spot to insert the colon.
(t "[.?!:][])}\"']*$")))
(sentence-end-without-space-list
(string-to-list sentence-end-without-space)))
(while (re-search-forward eol-double-space-re to t)
(or (>= (point) to) (memq (char-before) '(?\t ?\s))
(memq (char-after (match-beginning 0))
sentence-end-without-space-list)
(insert-and-inherit ?\s))))
(goto-char from)
(if enable-multibyte-characters
;; Delete unnecessary newlines surrounded by words. The
;; character category `|' means that we can break a line at the
;; character. And, char-table
;; `fill-nospace-between-words-table' tells how to concatenate
;; words. If a character has non-nil value in the table, never
;; put spaces between words, thus delete a newline between them.
;; Otherwise, delete a newline only when a character preceding a
;; newline has non-nil value in that table.
(while (search-forward "\n" to t)
(if (get-text-property (match-beginning 0) 'fill-space)
(replace-match (get-text-property (match-beginning 0) 'fill-space))
(let ((prev (char-before (match-beginning 0)))
(next (following-char)))
(if (and (if fill-separate-heterogeneous-words-with-space
(and (aref (char-category-set next) ?|)
(aref (char-category-set prev) ?|))
(or (aref (char-category-set next) ?|)
(aref (char-category-set prev) ?|)))
(or (aref fill-nospace-between-words-table next)
(aref fill-nospace-between-words-table prev)))
(delete-char -1))))))
(goto-char from)
(skip-chars-forward " \t")
;; Then change all newlines to spaces.
(subst-char-in-region from to ?\n ?\s)
(if (and nosqueeze (not (eq justify 'full)))
nil
(canonically-space-region (or squeeze-after (point)) to)
;; Remove trailing whitespace.
;; Maybe canonically-space-region should do that.
(goto-char to) (delete-char (- (skip-chars-backward " \t"))))
(goto-char from))