Function: fill-flowed

fill-flowed is an autoloaded and byte-compiled function defined in flow-fill.el.gz.

Signature

(fill-flowed &optional BUFFER DELETE-SPACE)

Documentation

Apply RFC2646 decoding to BUFFER.

If BUFFER is nil, default to the current buffer.

If DELETE-SPACE, delete RFC2646 spaces padding at the end of lines.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/flow-fill.el.gz
;;;###autoload
(defun fill-flowed (&optional buffer delete-space)
  "Apply RFC2646 decoding to BUFFER.
If BUFFER is nil, default to the current buffer.

If DELETE-SPACE, delete RFC2646 spaces padding at the end of
lines."
  (with-current-buffer (or buffer (current-buffer))
    (let ((fill-column  (eval fill-flowed-display-column t)))
      (goto-char (point-min))
      (while (not (eobp))
        (cond
         ((and (looking-at "^>+")
               (eq (char-before (line-end-position)) ?\s))
          (let ((prefix (match-string 0)))
            ;; Insert a space character after the quote signs for more
            ;; pleasant reading of quoted lines.
            (goto-char (match-end 0))
            (unless (looking-at " ")
              (insert " "))
            (while (and (eq (char-before (line-end-position)) ?\s)
                        (not (eobp))
                        (save-excursion
                          (forward-line 1)
                          (looking-at (format "\\(%s ?\\)[^>]" prefix))))
              (end-of-line)
              (when (and (not (eobp))
                         (save-excursion
                           (forward-line 1)
                           (looking-at (format "\\(%s ?\\)[^>]" prefix))))
                ;; Delete the newline and the quote at the start of the
                ;; next line.
                (delete-region (point) (match-end 1))))
                (ignore-errors
		  (let ((fill-prefix (concat prefix " "))
                        adaptive-fill-mode)
		    (fill-region (line-beginning-position)
                                 (line-end-position)
                                 'left 'nosqueeze)))))
          (t
          ;; Delete the newline.
          (when (eq (following-char) ?\s)
            (delete-char 1))
          ;; Hack: Don't do the flowing on the signature line.
          (when (and (not (looking-at "-- $"))
                     (eq (char-before (line-end-position)) ?\s))
            (while (and (not (eobp))
                        (eq (char-before (line-end-position)) ?\s))
              (end-of-line)
              (when delete-space
                (delete-char -1))
              (delete-char 1))
            (ignore-errors
		(let ((fill-prefix ""))
		  (fill-region (line-beginning-position)
                               (line-end-position)
			       'left 'nosqueeze))))))
        (forward-line 1)))))