comparison lisp/gnus/message.el @ 32967:7625203dacf3

2000-10-27 ShengHuo ZHU <zsh@cs.rochester.edu> * message.el (message-send-mail-partially): Replace the header delimiter with a blank line. (message-sending-message): New variable. (message-send): Use it. (message-default-charset): Default value for non-Mule Emacsen. (message-alternative-emails): New. (message-use-alternative-email-as-from): New. (message-setup): Use them. (message-default-charset): Set default value in non-MULE XEmacsen as iso-8859-1. 2000-10-27 Emerick Rogul <emerick@csa.bu.edu> * message.el (message-setup-fill-variables): New variable. (message-mode): Use it. 2000-10-27 Bjorn Torkelsson <torkel@hpc2n.umu.se> * message.el: xemacs cleanup (use featurep ' xemacs) 2000-10-27 Stanislav Shalunov <shalunov@internet2.edu> * message.el (message-make-in-reply-to): In-Reply-To is message-id (see DRUMS). 2000-10-27 Simon Josefsson <simon@josefsson.org> * message.el (message-send): Make sure error is signalled if no send method is specified.
author Dave Love <fx@gnu.org>
date Fri, 27 Oct 2000 17:58:21 +0000
parents 352449d35643
children e07128cd595f
comparison
equal deleted inserted replaced
32966:c75de0056053 32967:7625203dacf3
1 ;;; message.el --- composing mail and news messages 1 ;;; message.el --- composing mail and news messages
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc. 3 ;; Free Software Foundation, Inc.
4 4
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> 5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Maintainer: bugs@gnus.org
6 ;; Keywords: mail, news 7 ;; Keywords: mail, news
7 8
8 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
9 10
10 ;; GNU Emacs is free software; you can redistribute it and/or modify 11 ;; GNU Emacs is free software; you can redistribute it and/or modify
662 Valid valued are `unique' and `unsent'." 663 Valid valued are `unique' and `unsent'."
663 :group 'message-buffers 664 :group 'message-buffers
664 :type '(choice (const :tag "unique" unique) 665 :type '(choice (const :tag "unique" unique)
665 (const :tag "unsent" unsent))) 666 (const :tag "unsent" unsent)))
666 667
667 (defcustom message-default-charset nil 668 (defcustom message-default-charset
668 "Default charset used in non-MULE XEmacsen." 669 (and (not (mm-multibyte-p)) 'iso-8859-1)
670 "Default charset used in non-MULE Emacsen.
671 If nil, you might be asked to input the charset."
669 :group 'message 672 :group 'message
670 :type 'symbol) 673 :type 'symbol)
671 674
672 (defcustom message-dont-reply-to-names 675 (defcustom message-dont-reply-to-names
673 (and (boundp 'rmail-dont-reply-to-names) rmail-dont-reply-to-names) 676 (and (boundp 'rmail-dont-reply-to-names) rmail-dont-reply-to-names)
898 should be sent in several parts. If it is nil, the size is unlimited." 901 should be sent in several parts. If it is nil, the size is unlimited."
899 :group 'message-buffers 902 :group 'message-buffers
900 :type '(choice (const :tag "unlimited" nil) 903 :type '(choice (const :tag "unlimited" nil)
901 (integer 1000000))) 904 (integer 1000000)))
902 905
906 (defcustom message-alternative-emails nil
907 "A regexp to match the alternative email addresses.
908 The first matched address (not primary one) is used in the From field."
909 :group 'message-headers
910 :type '(choice (const :tag "Always use primary" nil)
911 regexp))
912
903 ;;; Internal variables. 913 ;;; Internal variables.
904 914
915 (defvar message-sending-message "Sending...")
905 (defvar message-buffer-list nil) 916 (defvar message-buffer-list nil)
906 (defvar message-this-is-news nil) 917 (defvar message-this-is-news nil)
907 (defvar message-this-is-mail nil) 918 (defvar message-this-is-mail nil)
908 (defvar message-draft-article nil) 919 (defvar message-draft-article nil)
909 (defvar message-mime-part nil) 920 (defvar message-mime-part nil)
2106 (undo-boundary) 2117 (undo-boundary)
2107 (let ((inhibit-read-only t)) 2118 (let ((inhibit-read-only t))
2108 (put-text-property (point-min) (point-max) 'read-only nil)) 2119 (put-text-property (point-min) (point-max) 'read-only nil))
2109 (message-fix-before-sending) 2120 (message-fix-before-sending)
2110 (run-hooks 'message-send-hook) 2121 (run-hooks 'message-send-hook)
2111 (message "Sending...") 2122 (message message-sending-message)
2112 (let ((alist message-send-method-alist) 2123 (let ((alist message-send-method-alist)
2113 (success t) 2124 (success t)
2114 elem sent) 2125 elem sent)
2115 (while (and success 2126 (while (and success
2116 (setq elem (pop alist))) 2127 (setq elem (pop alist)))
2117 (when (or (not (funcall (cadr elem))) 2128 (when (funcall (cadr elem))
2118 (and (or (not (memq (car elem) 2129 (when (and (or (not (memq (car elem)
2119 message-sent-message-via)) 2130 message-sent-message-via))
2120 (y-or-n-p 2131 (y-or-n-p
2121 (format 2132 (format
2122 "Already sent message via %s; resend? " 2133 "Already sent message via %s; resend? "
2123 (car elem)))) 2134 (car elem))))
2124 (setq success (funcall (caddr elem) arg)))) 2135 (setq success (funcall (caddr elem) arg)))
2125 (setq sent t))) 2136 (setq sent t))))
2126 (unless (or sent (not success)) 2137 (unless (or sent (not success))
2127 (error "No methods specified to send by")) 2138 (error "No methods specified to send by"))
2128 (when (and success sent) 2139 (when (and success sent)
2129 (message-do-fcc) 2140 (message-do-fcc)
2130 (save-excursion 2141 (save-excursion
2192 (eval (car actions))))) 2203 (eval (car actions)))))
2193 (pop actions))) 2204 (pop actions)))
2194 2205
2195 (defun message-send-mail-partially () 2206 (defun message-send-mail-partially ()
2196 "Sendmail as message/partial." 2207 "Sendmail as message/partial."
2208 ;; replace the header delimiter with a blank line
2209 (goto-char (point-min))
2210 (re-search-forward
2211 (concat "^" (regexp-quote mail-header-separator) "\n"))
2212 (replace-match "\n")
2213 (run-hooks 'message-send-mail-hook)
2197 (let ((p (goto-char (point-min))) 2214 (let ((p (goto-char (point-min)))
2198 (tembuf (message-generate-new-buffer-clone-locals " message temp")) 2215 (tembuf (message-generate-new-buffer-clone-locals " message temp"))
2199 (curbuf (current-buffer)) 2216 (curbuf (current-buffer))
2200 (id (message-make-message-id)) (n 1) 2217 (id (message-make-message-id)) (n 1)
2201 plist total header required-mail-headers) 2218 plist total header required-mail-headers)
3030 (int-to-string (count-lines (point) (point-max)))))) 3047 (int-to-string (count-lines (point) (point-max))))))
3031 3048
3032 (defun message-make-in-reply-to () 3049 (defun message-make-in-reply-to ()
3033 "Return the In-Reply-To header for this message." 3050 "Return the In-Reply-To header for this message."
3034 (when message-reply-headers 3051 (when message-reply-headers
3035 (let ((from (mail-header-from message-reply-headers)) 3052 (mail-header-message-id message-reply-headers)))
3036 (date (mail-header-date message-reply-headers)))
3037 (when from
3038 (let ((stop-pos
3039 (string-match " *at \\| *@ \\| *(\\| *<" from)))
3040 (concat (if (and stop-pos
3041 (not (zerop stop-pos)))
3042 (substring from 0 stop-pos) from)
3043 "'s message of \""
3044 (if (or (not date) (string= date ""))
3045 "(unknown date)" date)
3046 "\""))))))
3047 3053
3048 (defun message-make-distribution () 3054 (defun message-make-distribution ()
3049 "Make a Distribution header." 3055 "Make a Distribution header."
3050 (let ((orig-distribution (message-fetch-reply-field "distribution"))) 3056 (let ((orig-distribution (message-fetch-reply-field "distribution")))
3051 (cond ((message-functionp message-distribution-function) 3057 (cond ((message-functionp message-distribution-function)
3584 (copy-sequence message-required-mail-headers)))))) 3590 (copy-sequence message-required-mail-headers))))))
3585 (run-hooks 'message-signature-setup-hook) 3591 (run-hooks 'message-signature-setup-hook)
3586 (message-insert-signature) 3592 (message-insert-signature)
3587 (save-restriction 3593 (save-restriction
3588 (message-narrow-to-headers) 3594 (message-narrow-to-headers)
3595 (if message-alternative-emails
3596 (message-use-alternative-email-as-from))
3589 (run-hooks 'message-header-setup-hook)) 3597 (run-hooks 'message-header-setup-hook))
3590 (set-buffer-modified-p nil) 3598 (set-buffer-modified-p nil)
3591 (setq buffer-undo-list nil) 3599 (setq buffer-undo-list nil)
3592 (run-hooks 'message-setup-hook) 3600 (run-hooks 'message-setup-hook)
3593 (message-position-point) 3601 (message-position-point)
4106 (if message-forward-as-mime 4114 (if message-forward-as-mime
4107 (insert-buffer-substring cur) 4115 (insert-buffer-substring cur)
4108 (mml-insert-buffer cur)) 4116 (mml-insert-buffer cur))
4109 (if message-forward-show-mml 4117 (if message-forward-show-mml
4110 (insert-buffer-substring cur) 4118 (insert-buffer-substring cur)
4111 (mm-with-unibyte-current-buffer 4119 (mml-insert-buffer cur)))
4112 (mml-insert-buffer cur))))
4113 (setq e (point)) 4120 (setq e (point))
4114 (if message-forward-as-mime 4121 (if message-forward-as-mime
4115 (if digest 4122 (if digest
4116 (insert "<#/multipart>\n") 4123 (insert "<#/multipart>\n")
4117 (if message-forward-show-mml 4124 (if message-forward-show-mml
4528 (minibuffer-setup-hook 'mail-abbrevs-setup)) 4535 (minibuffer-setup-hook 'mail-abbrevs-setup))
4529 (read-from-minibuffer prompt)) 4536 (read-from-minibuffer prompt))
4530 (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook)) 4537 (let ((minibuffer-setup-hook 'mail-abbrev-minibuffer-setup-hook))
4531 (read-string prompt)))) 4538 (read-string prompt))))
4532 4539
4540 (defun message-use-alternative-email-as-from ()
4541 (require 'mail-utils)
4542 (let* ((fields '("To" "Cc"))
4543 (emails
4544 (split-string
4545 (mail-strip-quoted-names
4546 (mapconcat 'message-fetch-reply-field fields ","))
4547 "[ \f\t\n\r\v,]+"))
4548 email)
4549 (while emails
4550 (if (string-match message-alternative-emails (car emails))
4551 (setq email (car emails)
4552 emails nil))
4553 (pop emails))
4554 (unless (or (not email) (equal email user-mail-address))
4555 (goto-char (point-max))
4556 (insert "From: " email "\n"))))
4557
4533 (provide 'message) 4558 (provide 'message)
4534 4559
4535 (run-hooks 'message-load-hook) 4560 (run-hooks 'message-load-hook)
4536 4561
4537 ;; Local Variables: 4562 ;; Local Variables: