• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/mail/

Lines Matching +defs:mail +defs:citation +defs:hook

1 ;;; sendmail.el --- mail sending commands for Emacs.  -*- byte-compile-dynamic: t -*-
7 ;; Keywords: mail
28 ;; This mode provides mail-sending facilities from within Emacs. It is
42 :prefix "mail-"
43 :group 'mail)
45 (defcustom mail-setup-with-from t
56 (t "fakemail")) ;In ../etc, to interface to /bin/mail.
58 :group 'mail
62 (defcustom mail-from-style 'angles
75 Emacs to pass the proper email address from `user-mail-address'
77 controlled by a separate variable, `mail-specify-envelope-from'."
84 (defcustom mail-specify-envelope-from nil
85 "If non-nil, specify the envelope-from address when sending mail.
87 the variable `mail-envelope-from', with `user-mail-address' as fallback.
91 smtpmail -- if you use feedmail to send mail, see instead the
97 (defcustom mail-envelope-from nil
98 "If non-nil, designate the envelope-from address when sending mail.
99 This only has an effect if `mail-specify-envelope-from' is non-nil.
103 `user-mail-address' is used)."
107 (const :tag "Use `user-mail-address'" nil))
111 (defcustom mail-self-blind nil
119 (defcustom mail-interactive nil
121 nil means let mailer mail back a message to report errors."
125 (defcustom mail-yank-ignored-headers
127 (regexp-opt '("via" "mail-from" "origin" "status" "remailed"
129 "in-reply-to" "return-path" "mail-reply-to"
130 "mail-followup-to") "\\(?:")
140 (put 'send-mail-function 'standard-value
147 (defcustom send-mail-function
151 "Function to call to send the current buffer as mail.
154 that matches the variable `mail-header-separator'.
155 This is used by the default mail-sending commands. See also
156 `message-send-mail-function' for use with the Message package."
165 (defcustom mail-header-separator "--text follows this line--"
170 ;; Set up mail-header-separator for use as a category text property.
171 (put 'mail-header-separator 'rear-nonsticky '(category))
177 ;;(put 'mail-header-separator 'read-only t)
180 (defcustom mail-archive-file-name nil
187 (defcustom mail-default-reply-to nil
190 when you first send mail."
195 (defcustom mail-alias-file nil
204 (defcustom mail-personal-alias-file "~/.mailrc"
205 "If non-nil, the name of the user's personal mail alias file.
213 (defcustom mail-setup-hook nil
214 "Normal hook, run each time a new outgoing mail message is initialized.
215 The function `mail-setup' runs this hook."
216 :type 'hook
217 :options '(fortune-to-signature spook mail-abbrevs-setup)
221 (defvar mail-aliases t
222 "Alist of mail address aliases,
223 or t meaning should be initialized from your mail aliases file.
224 \(The file's name is normally `~/.mailrc', but `mail-personal-alias-file'
229 (defvar mail-alias-modtime nil
230 "The modification time of your mail alias file when it was last examined.")
233 (defcustom mail-yank-prefix nil
240 (defcustom mail-indentation-spaces 3
242 Used by `mail-yank-original' via `mail-indent-citation'."
246 (defvar mail-yank-hooks nil
247 "Obsolete hook for modifying a citation just inserted in the mail buffer.
248 Each hook function can find the citation between (point) and (mark t).
249 And each hook function should leave point and mark around the citation
252 This is a normal hook, misnamed for historical reasons.
253 It is semi-obsolete and mail agents should no longer use it.")
256 (defcustom mail-citation-hook nil
257 "Hook for modifying a citation just inserted in the mail buffer.
258 Each hook function can find the citation between (point) and (mark t),
259 and should leave point and mark around the citation text as modified.
260 The hook functions can find the header of the cited message
261 in the variable `mail-citation-header', whether or not this is included
264 If this hook is entirely empty (nil), a default action is taken
266 :type 'hook
269 (defvar mail-citation-header nil
270 "While running `mail-citation-hook', this variable holds the message header.
271 This enables the hook functions to see the whole message header
275 (defcustom mail-citation-prefix-regexp "[ \t]*[-a-z0-9A-Z]*>+[ \t]*\\|[ \t]*"
276 "Regular expression to match a citation prefix plus whitespace.
277 It should match whatever sort of citation prefixes you want to handle,
284 (defvar mail-abbrevs-loaded nil)
285 (defvar mail-mode-map
287 (define-key map "\M-\t" 'mail-complete)
289 (define-key map "\C-c\C-f\C-t" 'mail-to)
290 (define-key map "\C-c\C-f\C-b" 'mail-bcc)
291 (define-key map "\C-c\C-f\C-f" 'mail-fcc)
292 (define-key map "\C-c\C-f\C-c" 'mail-cc)
293 (define-key map "\C-c\C-f\C-s" 'mail-subject)
294 (define-key map "\C-c\C-f\C-r" 'mail-reply-to)
295 (define-key map "\C-c\C-f\C-a" 'mail-mail-reply-to) ; author
296 (define-key map "\C-c\C-f\C-l" 'mail-mail-followup-to) ; list
297 (define-key map "\C-c\C-t" 'mail-text)
298 (define-key map "\C-c\C-y" 'mail-yank-original)
299 (define-key map "\C-c\C-r" 'mail-yank-region)
300 (define-key map [remap split-line] 'mail-split-line)
301 (define-key map "\C-c\C-q" 'mail-fill-yanked-message)
302 (define-key map "\C-c\C-w" 'mail-signature)
303 (define-key map "\C-c\C-v" 'mail-sent-via)
304 (define-key map "\C-c\C-c" 'mail-send-and-exit)
305 (define-key map "\C-c\C-s" 'mail-send)
306 (define-key map "\C-c\C-i" 'mail-attach-file)
308 (define-key map [menu-bar mail]
311 (define-key map [menu-bar mail fill]
312 '("Fill Citation" . mail-fill-yanked-message))
314 (define-key map [menu-bar mail yank]
315 '("Cite Original" . mail-yank-original))
317 (define-key map [menu-bar mail signature]
318 '("Insert Signature" . mail-signature))
320 (define-key map [menu-bar mail mail-sep]
323 (define-key map [menu-bar mail cancel]
324 '("Cancel" . mail-dont-send))
326 (define-key map [menu-bar mail send-stay]
327 '("Send, Keep Editing" . mail-send))
329 (define-key map [menu-bar mail send]
330 '("Send Message" . mail-send-and-exit))
336 '("Text" . mail-text))
339 '("Expand Aliases" . expand-mail-aliases))
342 '("Sent Via" . mail-sent-via))
344 (define-key map [menu-bar headers mail-reply-to]
345 '("Mail Reply To" . mail-mail-reply-to))
347 (define-key map [menu-bar headers mail-followup-to]
348 '("Mail Followup To" . mail-mail-followup-to))
351 '("Reply-To" . mail-reply-to))
354 '("Bcc" . mail-bcc))
357 '("Fcc" . mail-fcc))
360 '("Cc" . mail-cc))
363 '("Subject" . mail-subject))
366 '("To" . mail-to))
370 (autoload 'build-mail-aliases "mailalias"
371 "Read mail aliases from user's personal aliases file and set `mail-aliases'."
374 (autoload 'expand-mail-aliases "mailalias"
375 "Expand all mail aliases in suitable header fields found between BEG and END.
382 (defcustom mail-signature nil
383 "Text inserted at end of mail buffer when a message is initialized.
384 If t, it means to insert the contents of the file `mail-signature-file'.
395 (put 'mail-signature 'risky-local-variable t)
398 (defcustom mail-signature-file "~/.signature"
399 "File containing the text inserted at end of mail buffer."
404 (defcustom mail-default-directory "~/"
405 "Directory for mail buffers.
406 Value of `default-directory' for mail buffers.
407 This directory is used for auto-save files of mail buffers."
412 (defvar mail-reply-action nil)
413 (defvar mail-send-actions nil
415 (put 'mail-reply-action 'permanent-local t)
416 (put 'mail-send-actions 'permanent-local t)
419 (defcustom mail-default-headers nil
427 (defcustom mail-bury-selects-summary t
428 "If non-nil, try to show RMAIL summary buffer after returning from mail.
429 The functions \\[mail-send-on-exit] or \\[mail-dont-send] select
436 (defcustom mail-send-nonascii 'mime
437 "Specify whether to allow sending non-ASCII characters in mail.
442 Including non-ASCII characters in a mail message can be problematical
447 (defcustom mail-use-dsn nil
457 ;; Note: could use /usr/ucb/mail instead of sendmail;
459 (defvar mail-mailer-swallows-blank-line
477 (defvar mail-mode-syntax-table
482 "Syntax table used while in `mail-mode'.")
484 (defvar mail-font-lock-keywords
495 ;; Use EVAL to delay in case `mail-header-separator' gets changed.
497 (let ((separator (if (zerop (length mail-header-separator))
499 (regexp-quote mail-header-separator))))
517 (when mail-personal-alias-file
518 (let ((modtime (nth 5 (file-attributes mail-personal-alias-file))))
519 (or (equal mail-alias-modtime modtime)
520 (setq mail-alias-modtime modtime
521 mail-aliases t)))))
523 (defun mail-setup (to subject in-reply-to cc replybuffer actions)
524 (or mail-default-reply-to
525 (setq mail-default-reply-to (getenv "REPLYTO")))
527 (if (eq mail-aliases t)
529 (setq mail-aliases nil)
530 (when mail-personal-alias-file
531 (if (file-exists-p mail-personal-alias-file)
532 (build-mail-aliases)))))
540 (setq mail-send-actions actions)
541 (setq mail-reply-action replybuffer)
543 (if mail-setup-with-from
544 (mail-insert-from-field))
549 ;; on the assumption that mail-strip-quoted-names
577 (if mail-default-headers
578 (insert mail-default-headers))
579 (if mail-default-reply-to
580 (insert "Reply-to: " mail-default-reply-to "\n"))
581 (if mail-self-blind
582 (insert "BCC: " user-mail-address "\n"))
583 (if mail-archive-file-name
584 (insert "FCC: " mail-archive-file-name "\n"))
587 (insert mail-header-separator "\n")
589 'category 'mail-header-separator)
592 (cond ((eq mail-signature t)
593 (if (file-exists-p mail-signature-file)
596 (insert-file-contents mail-signature-file))))
597 ((stringp mail-signature)
598 (insert mail-signature))
600 (eval mail-signature)))
606 (run-hooks 'mail-setup-hook))
609 (defcustom mail-mode-hook nil
612 :type 'hook
615 (defvar mail-mode-abbrev-table text-mode-abbrev-table)
617 (define-derived-mode mail-mode text-mode "Mail"
618 "Major mode for editing mail to be sent.
621 \\[mail-send] mail-send (send the message)
622 \\[mail-send-and-exit] mail-send-and-exit (send the message and exit)
625 \\[mail-to] move to To: \\[mail-subject] move to Subj:
626 \\[mail-bcc] move to BCC: \\[mail-cc] move to CC:
627 \\[mail-fcc] move to FCC: \\[mail-reply-to] move to Reply-To:
628 \\[mail-mail-reply-to] move to Mail-Reply-To:
629 \\[mail-mail-followup-to] move to Mail-Followup-To:
630 \\[mail-text] move to message text.
631 \\[mail-signature] mail-signature (insert `mail-signature-file' file).
632 \\[mail-yank-original] mail-yank-original (insert current message, in Rmail).
633 \\[mail-fill-yanked-message] mail-fill-yanked-message (fill what was yanked).
634 \\[mail-sent-via] mail-sent-via (add a sent-via field for each To or CC).
635 Turning on Mail mode runs the normal hooks `text-mode-hook' and
636 `mail-mode-hook' (in that order)."
637 (make-local-variable 'mail-reply-action)
638 (make-local-variable 'mail-send-actions)
641 (setq font-lock-defaults '(mail-font-lock-keywords t t))
644 (setq normal-auto-fill-function 'mail-mode-auto-fill)
646 (setq fill-paragraph-function 'mail-mode-fill-paragraph)
648 ;; anything if mail-yank-prefix is set to a non-nil value).
649 (set (make-local-variable 'comment-start) mail-yank-prefix)
650 (if mail-yank-prefix
652 (concat "^" (regexp-quote mail-yank-prefix) "[ \t]*")))
665 (setq paragraph-separate (concat (regexp-quote mail-header-separator)
672 (defun mail-header-end ()
680 (defun mail-text-start ()
689 (defun mail-sendmail-delimit-header ()
693 (insert mail-header-separator)
696 (defun mail-sendmail-undelimit-header ()
702 (defun mail-mode-auto-fill ()
705 (if (< (point) (mail-header-end))
718 (defun mail-mode-fill-paragraph (arg)
720 (if (< (point) (mail-header-end))
737 "mail-reply-to" "mail-followup-to"
756 (defun mail-send-and-exit (&optional arg)
757 "Send message like `mail-send', then, if no errors, exit from mail buffer.
760 (mail-send)
761 (mail-bury arg))
763 (defun mail-dont-send (&optional arg)
767 (mail-bury arg))
769 (defun mail-bury (&optional arg)
770 "Bury this mail buffer."
774 (cdr (assq 'mail-dedicated-frame (frame-parameters))))
789 (and mail-bury-selects-summary
801 (defcustom mail-send-hook nil
802 "Hook run just before sending mail with `mail-send'."
803 :type 'hook
808 (defcustom mail-mailing-lists nil "\
817 (defun mail-send ()
819 If `mail-interactive' is non-nil, wait for success indication
825 (y-or-n-p "Send buffer contents as mail message? ")
830 (ml (when mail-mailing-lists
832 ;; `mail-strip-quoted-names' on addresses before matching
836 (regexp-opt mail-mailing-lists t)
841 (let* ((to (mail-fetch-field "to" nil t))
842 (cc (mail-fetch-field "cc" nil t))
844 (mail-strip-quoted-names
849 (unless (mail-fetch-field "mail-followup-to")
850 (goto-char (mail-header-end))
863 (unless (mail-fetch-field "mail-reply-to")
864 (goto-char (mail-header-end))
866 (or (mail-fetch-field "reply-to")
867 user-mail-address)
869 (unless (memq mail-send-nonascii '(t mime))
873 (if (eq mail-send-nonascii 'query)
879 (re-search-forward (regexp-quote mail-header-separator) (point-max) t)
888 (run-hooks 'mail-send-hook)
890 (funcall send-mail-function)
892 (while mail-send-actions
894 (apply (car (car mail-send-actions))
895 (cdr (car mail-send-actions)))
897 (setq mail-send-actions (cdr mail-send-actions)))
905 (defun mail-envelope-from ()
906 "Return the envelope mail address to use when sending mail.
907 This function uses `mail-envelope-from'."
908 (if (eq mail-envelope-from 'header)
909 (nth 1 (mail-extract-address-components
910 (mail-fetch-field "From")))
911 mail-envelope-from))
915 ;; It is called via the variable send-mail-function.
919 "*Coding system for encoding the outgoing mail.
927 "Default coding system for encoding the outgoing mail.
936 (defun mail-insert-from-field ()
937 (let* ((login user-mail-address)
943 (cond ((eq mail-from-style 'angles)
962 ((eq mail-from-style 'parens)
986 ((null mail-from-style)
988 ((eq mail-from-style 'system-default)
990 (t (error "Invalid value for `mail-from-style'")))))
993 "Send the current mail buffer using the Sendmail package.
994 This is a suitable value for `send-mail-function'. It sends using the
996 (require 'mail-utils)
997 (let ((errbuf (if mail-interactive
1012 ;; local binding in the mail buffer will take effect.
1014 (and mail-specify-envelope-from
1015 (or (mail-envelope-from) user-mail-address))))
1027 (goto-char (mail-header-end))
1031 (if mail-aliases
1032 (expand-mail-aliases (point-min) delimline))
1053 (append (mail-parse-comma-list)
1065 ;;; (require 'mail-utils)
1067 ;;; (mail-strip-quoted-names
1070 ;;; (mail-fetch-field "From")))
1087 (mail-insert-from-field))
1091 (and (eq mail-send-nonascii 'mime)
1106 (if (eval mail-mailer-swallows-blank-line)
1113 (mail-do-fcc delimline)))
1114 (if mail-interactive
1133 (and mail-alias-file
1134 (list (concat "-oA" mail-alias-file)))
1135 (if mail-interactive
1139 ;; These mean "report errors by mail"
1150 (if mail-use-dsn
1152 mail-use-dsn ",")))
1160 (if mail-interactive
1172 (defun mail-do-fcc (header-end)
1199 (require 'mail-utils)
1200 (insert (mail-rfc822-time-zone time) " ")
1242 ;; Unix mail message.
1247 "Date: " (mail-rfc822-date) "\n")
1277 (mail-file-babyl-p fcc))
1283 (with-current-buffer (get-buffer-create " mail-temp")
1287 (mail-rfc822-date) "\n")
1299 (defun mail-sent-via ()
1304 (let ((end (copy-marker (mail-header-end)))
1322 (defun mail-to ()
1326 (mail-position-on-field "To"))
1328 (defun mail-subject ()
1332 (mail-position-on-field "Subject"))
1334 (defun mail-cc ()
1338 (or (mail-position-on-field "cc" t)
1339 (progn (mail-position-on-field "to")
1342 (defun mail-bcc ()
1346 (or (mail-position-on-field "bcc" t)
1347 (progn (mail-position-on-field "to")
1350 (defun mail-fcc (folder)
1354 (or (mail-position-on-field "fcc" t) ;Put new field after exiting FCC.
1355 (mail-position-on-field "to"))
1358 (defun mail-reply-to ()
1362 (mail-position-on-field "Reply-To"))
1364 (defun mail-mail-reply-to ()
1369 (or (mail-position-on-field "mail-reply-to" t)
1370 (progn (mail-position-on-field "to")
1373 (defun mail-mail-followup-to ()
1378 (or (mail-position-on-field "mail-followup-to" t)
1379 (progn (mail-position-on-field "to")
1382 (defun mail-position-on-field (field &optional soft)
1385 (setq end (mail-header-end))
1399 (defun mail-text ()
1403 (goto-char (mail-text-start)))
1406 (defun mail-signature (&optional atpoint)
1407 "Sign letter with signature based on `mail-signature-file'.
1417 (if (stringp mail-signature)
1418 (insert mail-signature)
1420 (insert-file-contents (expand-file-name mail-signature-file)))))
1422 (defun mail-fill-yanked-message (&optional justifyp)
1427 (goto-char (mail-text-start))
1431 mail-citation-prefix-regexp)))
1433 (defun mail-indent-citation ()
1438 Normally, indent each nonblank line `mail-indentation-spaces' spaces.
1439 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line."
1440 (mail-yank-clear-headers (region-beginning) (region-end))
1441 (if (null mail-yank-prefix)
1443 mail-indentation-spaces)
1448 (insert mail-yank-prefix)
1451 (defun mail-yank-original (arg)
1455 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line.
1460 (if mail-reply-action
1462 (original mail-reply-action))
1478 (let ((mail-indentation-spaces (if arg (prefix-numeric-value arg)
1479 mail-indentation-spaces))
1483 (cond (mail-citation-hook
1484 ;; Bind mail-citation-header to the inserted
1486 (let ((mail-citation-header
1495 (run-hooks 'mail-citation-hook)))
1496 (mail-yank-hooks
1497 (run-hooks 'mail-yank-hooks))
1499 (mail-indent-citation)))))
1507 (defun mail-yank-clear-headers (start end)
1511 (if mail-yank-ignored-headers
1519 (re-search-forward mail-yank-ignored-headers nil t))
1526 (defun mail-yank-region (arg)
1530 However, if `mail-yank-prefix' is non-nil, insert that prefix on each line.
1535 (and (consp mail-reply-action)
1536 (eq (car mail-reply-action) 'insert-buffer)
1537 (with-current-buffer (nth 1 mail-reply-action)
1540 (let ((buffer (nth 1 mail-reply-action))
1545 ;; Insert the citation text.
1549 ;; Indent or otherwise annotate the citation text.
1552 (let ((mail-indentation-spaces (if arg (prefix-numeric-value arg)
1553 mail-indentation-spaces)))
1554 (if mail-citation-hook
1555 ;; Bind mail-citation-hook to the original message's header.
1556 (let ((mail-citation-header
1564 (run-hooks 'mail-citation-hook))
1565 (if mail-yank-hooks
1566 (run-hooks 'mail-yank-hooks)
1567 (mail-indent-citation))))))))
1569 (defun mail-split-line ()
1571 If the current line has `mail-yank-prefix', insert it on the new line."
1573 (split-line mail-yank-prefix))
1577 (defun mail-attach-file (&optional file)
1601 ;;;###autoload (add-hook 'same-window-buffer-names "*mail*")
1604 (defun mail (&optional noerase to subject in-reply-to cc replybuffer actions)
1606 When this function returns, the buffer `*mail*' is selected.
1609 Optionally, the signature file `mail-signature-file' can be inserted at the
1610 end; see the variable `mail-signature'.
1612 \\<mail-mode-map>
1613 While editing message, type \\[mail-send-and-exit] to send the message and exit.
1617 \\{mail-mode-map}
1619 If `mail-self-blind' is non-nil, a BCC to yourself is inserted
1622 If `mail-default-reply-to' is non-nil, it should be an address (a string);
1625 If `mail-archive-file-name' is non-nil, an FCC field with that file name
1628 The normal hook `mail-setup-hook' is run after the message is
1632 an existing modified `*mail*' buffer. If NOERASE is nil, the
1633 existing mail buffer is used, and the user is prompted whether to
1635 `new', a new mail buffer will be created instead of using the old
1653 ;;; It is easy enough to rename *mail* by hand with rename-buffer
1654 ;;; if you want to have multiple mail buffers.
1658 ;;; ;; If requested, look for a mail buffer that is modified and go to it.
1662 ;;; (get-buffer (if (= 1 index) "*mail*"
1663 ;;; (format "*mail*<%d>" index))))
1668 ;;; ;; This will never re-use an existing unmodified mail buffer
1674 ;;; ;; Look for existing unmodified mail buffer.
1676 ;;; (get-buffer (if (= 1 index) "*mail*"
1677 ;;; (format "*mail*<%d>" index))))
1682 ;;; (setq buffer (generate-new-buffer "*mail*")))
1688 ;;; (mail-mode)
1689 ;;; (mail-setup to subject in-reply-to cc replybuffer actions)
1692 ;;; (message "Auto save file for draft message exists; consider M-x mail-recover"))
1696 (pop-to-buffer (generate-new-buffer "*mail*"))
1698 (not (get-buffer "*mail*"))
1700 (pop-to-buffer "*mail*"))
1704 (file-name-as-directory mail-default-directory))))
1711 (mail-mode)
1713 ;; (in case the user has actually visited a file *mail*).
1733 (mail-setup to subject in-reply-to cc replybuffer actions)
1737 (message "Auto save file for draft message exists; consider M-x mail-recover"))
1740 (defun mail-recover-1 ()
1796 (switch-to-buffer-other-window "*mail*")
1811 (defun mail-recover ()
1812 "Recover interrupted mail composition from auto-save files.
1814 If the mail buffer has a current valid auto-save file,
1820 (switch-to-buffer "*mail*")
1821 ;; If *mail* didn't exist, set its directory, so that auto-saved
1824 (file-name-as-directory mail-default-directory))))
1827 (or (eq major-mode 'mail-mode)
1828 (mail-mode))
1845 (format "Recover mail draft from auto save file %s? "
1847 (error "mail-recover cancelled")
1856 (t (mail-recover-1)))))
1859 (defun mail-other-window (&optional noerase to subject in-reply-to cc replybuffer sendactions)
1860 "Like `mail' command, but display mail buffer in another window."
1867 (pop-to-buffer "*mail*"))
1868 (mail noerase to subject in-reply-to cc replybuffer sendactions))
1871 (defun mail-other-frame (&optional noerase to subject in-reply-to cc replybuffer sendactions)
1872 "Like `mail' command, but display mail buffer in another frame."
1879 (pop-to-buffer "*mail*"))
1880 (mail noerase to subject in-reply-to cc replybuffer sendactions))