Function: mail-mode

mail-mode is an autoloaded, interactive and byte-compiled function defined in sendmail.el.gz.

Signature

(mail-mode)

Documentation

Major mode for editing mail to be sent.

Like Text Mode but with these additional commands:

M-x mail-send (mail-send) mail-send (send the message)
M-x mail-send-and-exit (mail-send-and-exit) mail-send-and-exit (send the message and exit)

Here are commands that move to a header field (and create it if there isn't):
M-x mail-to (mail-to) move to To: M-x mail-subject (mail-subject) move to Subj:
M-x mail-bcc (mail-bcc) move to Bcc: M-x mail-cc (mail-cc) move to Cc:
M-x mail-fcc (mail-fcc) move to Fcc: M-x mail-reply-to (mail-reply-to) move to Reply-To:
         M-x mail-mail-reply-to (mail-mail-reply-to) move to Mail-Reply-To:
         M-x mail-mail-followup-to (mail-mail-followup-to) move to Mail-Followup-To:
M-x mail-text (mail-text) move to message text.
M-x mail-signature (mail-signature) mail-signature(var)/mail-signature(fun) (insert mail-signature-file file).
M-x mail-yank-original (mail-yank-original) mail-yank-original (insert current message, in Rmail).
M-x mail-fill-yanked-message (mail-fill-yanked-message) mail-fill-yanked-message (fill what was yanked).
M-x mail-insert-file (mail-insert-file) insert a text file into the message. M-x mail-add-attachment (mail-add-attachment) attach to the message a file as binary attachment. Turning on Mail mode runs the normal hooks text-mode-hook and mail-mode-hook (in that order).

Probably introduced at or before Emacs version 19.29.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mail/sendmail.el.gz
;;;###autoload
(define-derived-mode mail-mode text-mode "Mail"
  "Major mode for editing mail to be sent.
Like Text Mode but with these additional commands:

\\[mail-send]  `mail-send' (send the message)
\\[mail-send-and-exit]  `mail-send-and-exit' (send the message and exit)

Here are commands that move to a header field (and create it if there isn't):
	 \\[mail-to]  move to To:	\\[mail-subject]  move to Subj:
	 \\[mail-bcc]  move to Bcc:	\\[mail-cc]  move to Cc:
	 \\[mail-fcc]  move to Fcc:	\\[mail-reply-to] move to Reply-To:
         \\[mail-mail-reply-to]  move to Mail-Reply-To:
         \\[mail-mail-followup-to] move to Mail-Followup-To:
\\[mail-text]  move to message text.
\\[mail-signature]  `mail-signature' (insert `mail-signature-file' file).
\\[mail-yank-original]  `mail-yank-original' (insert current message, in Rmail).
\\[mail-fill-yanked-message]  `mail-fill-yanked-message' (fill what was yanked).
\\[mail-insert-file] insert a text file into the message.
\\[mail-add-attachment] attach to the message a file as binary attachment.
Turning on Mail mode runs the normal hooks `text-mode-hook' and
`mail-mode-hook' (in that order)."
  (make-local-variable 'mail-reply-action)
  (make-local-variable 'mail-send-actions)
  (make-local-variable 'mail-return-action)
  (setq-local mail-encode-mml nil)
  (setq buffer-offer-save t)
  (setq-local font-lock-defaults '(mail-font-lock-keywords t t))
  (make-local-variable 'paragraph-separate)
  (setq-local normal-auto-fill-function #'mail-mode-auto-fill)
  (setq-local fill-paragraph-function #'mail-mode-fill-paragraph)
  ;; Allow using comment commands to add/remove quoting (this only does
  ;; anything if mail-yank-prefix is set to a non-nil value).
  (setq-local comment-start mail-yank-prefix)
  (if mail-yank-prefix
      (setq-local comment-start-skip
                  (concat "^" (regexp-quote mail-yank-prefix) "[ \t]*")))
  ;; Also update the paragraph-separate entry if you change this.
  (setq-local adaptive-fill-regexp
              (concat "[ \t]*[-[:alnum:]]+>+[ \t]*\\|"
                      adaptive-fill-regexp))
  (setq-local adaptive-fill-first-line-regexp
              (concat "[ \t]*[-[:alnum:]]*>+[ \t]*\\|"
                      adaptive-fill-first-line-regexp))
  (add-hook 'completion-at-point-functions #'mail-completion-at-point-function
            nil 'local)
  ;; `-- ' precedes the signature.  `-----' appears at the start of the
  ;; lines that delimit forwarded messages.
  ;; Lines containing just >= 3 dashes, perhaps after whitespace,
  ;; are also sometimes used and should be separators.
  (setq paragraph-separate
        (if (zerop (length mail-header-separator))
	    (concat
		;; This is based on adaptive-fill-regexp (presumably
		;; the idea is to allow navigation etc of cited paragraphs).
		"\t*[-–!|#%;>*·•‣⁃◦ ]+$"
		"\\|[ \t]*[-[:alnum:]]*>+[ \t]*$\\|[ \t]*$\\|"
		"--\\( \\|-+\\)$\\|"
		page-delimiter)
	  (concat (regexp-quote mail-header-separator)
                  ;; This is based on adaptive-fill-regexp (presumably
                  ;; the idea is to allow navigation etc of cited paragraphs).
                  "$\\|\t*[-–!|#%;>*·•‣⁃◦ ]+$"
                  "\\|[ \t]*[-[:alnum:]]*>+[ \t]*$\\|[ \t]*$\\|"
                  "--\\( \\|-+\\)$\\|"
                  page-delimiter))))