*** empty log message ***
[emacs.git] / lisp / gnusmail.el
blob8ac0b06f02a2ed0d472e961f0cf13f191fd12507
1 ;;; gnusmail.el --- mail reply commands for GNUS newsreader
3 ;; Copyright (C) 1990 Masanobu UMEDA
4 ;; $Header: gnusmail.el,v 1.1 90/03/23 13:24:39 umerin Locked $
6 ;; This file is part of GNU Emacs.
8 ;; GNU Emacs is distributed in the hope that it will be useful,
9 ;; but WITHOUT ANY WARRANTY. No author or distributor
10 ;; accepts responsibility to anyone for the consequences of using it
11 ;; or for whether it serves any particular purpose or works at all,
12 ;; unless he says so in writing. Refer to the GNU Emacs General Public
13 ;; License for full details.
15 ;; Everyone is granted permission to copy, modify and redistribute
16 ;; GNU Emacs, but only under the conditions described in the
17 ;; GNU Emacs General Public License. A copy of this license is
18 ;; supposed to have been given to you along with GNU Emacs so you
19 ;; can know your rights and responsibilities. It should be in a
20 ;; file named COPYING. Among other things, the copyright notice
21 ;; and this notice must be preserved on all copies.
23 (require 'gnus)
25 ;; Provides mail reply and mail other window command using usual mail
26 ;; interface and mh-e interface.
27 ;;
28 ;; To use MAIL: set the variables gnus-mail-reply-method and
29 ;; gnus-mail-other-window-method to gnus-mail-reply-using-mail and
30 ;; gnus-mail-other-window-using-mail, respectively.
32 ;; To use MH-E: set the variables gnus-mail-reply-method and
33 ;; gnus-mail-other-window-method to gnus-mail-reply-using-mhe and
34 ;; gnus-mail-other-window-using-mhe, respectively.
36 (autoload 'news-mail-reply "rnewspost")
37 (autoload 'news-mail-other-window "rnewspost")
39 (autoload 'mh-send "mh-e")
40 (autoload 'mh-send-other-window "mh-e")
41 (autoload 'mh-find-path "mh-e")
42 (autoload 'mh-yank-cur-msg "mh-e")
44 ;;; Mail reply commands of GNUS Subject Mode
46 (defun gnus-Subject-mail-reply (yank)
47 "Reply mail to news author.
48 If prefix arg YANK is non-nil, original article is yanked automatically.
49 Customize the variable `gnus-mail-reply-method' to use another mailer."
50 (interactive "P")
51 (gnus-Subject-select-article)
52 (switch-to-buffer gnus-Article-buffer)
53 (widen)
54 (delete-other-windows)
55 (bury-buffer gnus-Article-buffer)
56 (funcall gnus-mail-reply-method yank))
58 (defun gnus-Subject-mail-reply-with-original ()
59 "Reply mail to news author with original article."
60 (interactive)
61 (gnus-Subject-mail-reply t))
63 (defun gnus-Subject-mail-other-window ()
64 "Compose mail in other window.
65 Customize the variable `gnus-mail-other-window-method' to use another mailer."
66 (interactive)
67 (gnus-Subject-select-article)
68 (switch-to-buffer gnus-Article-buffer)
69 (widen)
70 (delete-other-windows)
71 (bury-buffer gnus-Article-buffer)
72 (funcall gnus-mail-other-window-method))
75 ;;; Send mail using sendmail mail mode.
77 (defun gnus-mail-reply-using-mail (&optional yank)
78 "Compose reply mail using mail.
79 Optional argument YANK means yank original article."
80 (news-mail-reply)
81 (gnus-overload-functions)
82 (if yank
83 (let ((last (point)))
84 (goto-char (point-max))
85 (mail-yank-original nil)
86 (goto-char last)
87 )))
89 (defun gnus-mail-other-window-using-mail ()
90 "Compose mail other window using mail."
91 (news-mail-other-window)
92 (gnus-overload-functions))
95 ;;; Send mail using mh-e.
97 ;; The following mh-e interface is all cooperative works of
98 ;; tanaka@flab.fujitsu.CO.JP (TANAKA Hiroshi), kawabe@sra.CO.JP
99 ;; (Yoshikatsu Kawabe), and shingu@casund.cpr.canon.co.jp (Toshiaki
100 ;; SHINGU).
102 (defun gnus-mail-reply-using-mhe (&optional yank)
103 "Compose reply mail using mh-e.
104 Optional argument YANK means yank original article.
105 The command \\[mh-yank-cur-msg] yanks the original message into current buffer."
106 ;; First of all, prepare mhe mail buffer.
107 (let (from cc subject date to reply-to (buffer (current-buffer)))
108 (save-restriction
109 (gnus-Article-show-all-headers) ;I don't think this is really needed.
110 (setq from (gnus-fetch-field "from")
111 subject (let ((subject (gnus-fetch-field "subject")))
112 (if (and subject
113 (not (string-match "^[Rr][Ee]:.+$" subject)))
114 (concat "Re: " subject) subject))
115 reply-to (gnus-fetch-field "reply-to")
116 cc (gnus-fetch-field "cc")
117 date (gnus-fetch-field "date"))
118 (setq mh-show-buffer buffer)
119 (setq to (or reply-to from))
120 (mh-find-path)
121 (mh-send to (or cc "") subject)
122 (save-excursion
123 (mh-insert-fields
124 "In-reply-to:"
125 (concat
126 (substring from 0 (string-match " *at \\| *@ \\| *(\\| *<" from))
127 "'s message of " date)))
128 (setq mh-sent-from-folder buffer)
129 (setq mh-sent-from-msg 1)
131 ;; Then, yank original article if requested.
132 (if yank
133 (let ((last (point)))
134 (mh-yank-cur-msg)
135 (goto-char last)
138 (defun gnus-mail-other-window-using-mhe ()
139 "Compose mail other window using MH-E Mail."
140 (let ((to (read-string "To: "))
141 (cc (read-string "Cc: "))
142 (subject (read-string "Subject: " (gnus-fetch-field "subject"))))
143 (gnus-Article-show-all-headers) ;I don't think this is really needed.
144 (setq mh-show-buffer (current-buffer))
145 (mh-find-path)
146 (mh-send-other-window to cc subject)
147 (setq mh-sent-from-folder (current-buffer))
148 (setq mh-sent-from-msg 1)))
150 (provide 'gnusmail)
152 ;;; gnusmail.el ends here