Function: message-fix-before-sending
message-fix-before-sending is a byte-compiled function defined in
message.el.gz.
Signature
(message-fix-before-sending)
Documentation
Do various things to make the message nice before sending it.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
(defun message-fix-before-sending ()
"Do various things to make the message nice before sending it."
;; Make sure there's a newline at the end of the message.
(goto-char (point-max))
(unless (bolp)
(insert "\n"))
;; Make the hidden headers visible.
(widen)
;; Sort headers before sending the message.
(message-sort-headers)
;; Make invisible text visible.
;; It doesn't seem as if this is useful, since the invisible property
;; is clobbered by an after-change hook anyhow.
(message-check 'invisible-text
(let ((regions (message-text-with-property 'invisible))
from to)
(when regions
(while regions
(setq from (caar regions)
to (cdar regions)
regions (cdr regions))
(put-text-property from to 'invisible nil)
(overlay-put (make-overlay from to) 'face 'highlight))
(unless (yes-or-no-p
"Invisible text found and made visible; continue sending? ")
(error "Invisible text found and made visible")))))
(message-check 'illegible-text
(let (char found choice nul-chars)
(goto-char (point-min))
(setq nul-chars (save-excursion
(search-forward "\000" nil t)))
(while (progn
(skip-chars-forward mm-7bit-chars)
(when (get-text-property (point) 'no-illegible-text)
;; There is a signed or encrypted raw message part
;; that is considered to be safe.
(goto-char (or (next-single-property-change
(point) 'no-illegible-text)
(point-max))))
(setq char (char-after)))
(when (or (< char 128)
(and enable-multibyte-characters
(memq (char-charset char)
'(eight-bit-control eight-bit-graphic
;; Emacs 23, Bug#1770:
eight-bit
control-1))
(not (get-text-property
(point) 'untranslated-utf-8))))
(overlay-put (make-overlay (point) (1+ (point))) 'face 'highlight)
(setq found t))
(forward-char))
(when found
(setq choice
(car
(read-multiple-choice
(if nul-chars
"NUL characters found, which may cause problems. Continue sending?"
"Non-printable characters found. Continue sending?")
`((?d "delete" "Remove non-printable characters and send")
(?r "replace"
,(format
"Replace non-printable characters with \"%s\" and send"
message-replacement-char))
(?u "url-encode" "Use URL %hex encoding")
(?s "send" "Send as is without removing anything")
(?e "edit" "Continue editing")))))
(if (eq choice ?e)
(error "Non-printable characters"))
(goto-char (point-min))
(skip-chars-forward mm-7bit-chars)
(while (not (eobp))
(when (let ((char (char-after)))
(or (< char 128)
(and enable-multibyte-characters
;; FIXME: Wrong for Emacs 23 (unicode) and for
;; things like undecodable utf-8 (in Emacs 21?).
;; Should at least use find-coding-systems-region.
;; -- fx
(memq (char-charset char)
'(eight-bit-control eight-bit-graphic
;; Emacs 23, Bug#1770:
eight-bit
control-1))
(not (get-text-property
(point) 'untranslated-utf-8)))))
(cond
((eq choice ?i)
(message-kill-all-overlays))
((eq choice ?u)
(let ((char (get-byte (point))))
(delete-char 1)
(insert (format "%%%x" char))))
(t
(delete-char 1)
(when (eq choice ?r)
(insert message-replacement-char)))))
(forward-char)
(skip-chars-forward mm-7bit-chars)))))
(message-check 'bogus-recipient
;; Warn before sending a mail to an invalid address.
(message-check-recipients)))