Function: feedmail-fill-this-one

feedmail-fill-this-one is a byte-compiled function defined in feedmail.el.gz.

Signature

(feedmail-fill-this-one THIS-LINE THIS-LINE-END)

Documentation

In-place smart filling of the region bounded by the two arguments.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/feedmail.el.gz
(defun feedmail-fill-this-one (this-line this-line-end)
  "In-place smart filling of the region bounded by the two arguments."
  (feedmail-say-debug ">in-> feedmail-fill-this-one")
  (let ((fill-prefix "\t")
	(fill-column feedmail-fill-to-cc-fill-column))
    ;; The general idea is to break only on commas.  Collapse
    ;; multiple whitespace to a single blank; change
    ;; all the blanks to something unprintable; change the
    ;; commas to blanks; fill the region; change it back.
    (goto-char this-line)
    (while (re-search-forward "\\s-+" (1- this-line-end) t)
      (replace-match " "))

    (subst-char-in-region this-line this-line-end ?   2 t) ; blank->C-b
    (subst-char-in-region this-line this-line-end ?, ?  t) ; comma->blank

    (fill-region-as-paragraph this-line this-line-end)

    (subst-char-in-region this-line this-line-end ?  ?, t) ; comma<-blank
    (subst-char-in-region this-line this-line-end  2 ?  t) ; blank<-C-b

    ;; look out for missing commas before continuation lines
    (goto-char this-line)
    (while (re-search-forward "\\([^,]\\)\n\t[ ]*" this-line-end t)
      (replace-match "\\1,\n\t"))
    ))