*** empty log message ***
[bpt/emacs.git] / lisp / gnusmail.el
1 ;;; gnusmail.el --- mail reply commands for GNUS newsreader
2
3 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
4 ;; Last-Modified: 10 Jun 1992
5 ;; Keywords: news
6
7 ;; $Header: gnusmail.el,v 1.1 90/03/23 13:24:39 umerin Locked $
8
9 ;; Copyright (C) 1990 Free Software Foundation, Inc.
10
11 ;; This file is part of GNU Emacs.
12
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to
25 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 ;;; Commentary:
28
29 ;; Provides mail reply and mail other window command using usual mail
30 ;; interface and mh-e interface.
31 ;;
32 ;; To use MAIL: set the variables gnus-mail-reply-method and
33 ;; gnus-mail-other-window-method to gnus-mail-reply-using-mail and
34 ;; gnus-mail-other-window-using-mail, respectively.
35 ;;
36 ;; To use MH-E: set the variables gnus-mail-reply-method and
37 ;; gnus-mail-other-window-method to gnus-mail-reply-using-mhe and
38 ;; gnus-mail-other-window-using-mhe, respectively.
39
40 ;;; Code:
41
42 (require 'gnus)
43
44 (autoload 'news-mail-reply "rnewspost")
45 (autoload 'news-mail-other-window "rnewspost")
46
47 (autoload 'mh-send "mh-e")
48 (autoload 'mh-send-other-window "mh-e")
49 (autoload 'mh-find-path "mh-e")
50 (autoload 'mh-yank-cur-msg "mh-e")
51
52 ;;; Mail reply commands of GNUS Subject Mode
53
54 (defun gnus-Subject-mail-reply (yank)
55 "Reply mail to news author.
56 If prefix arg YANK is non-nil, original article is yanked automatically.
57 Customize the variable `gnus-mail-reply-method' to use another mailer."
58 (interactive "P")
59 (gnus-Subject-select-article)
60 (switch-to-buffer gnus-Article-buffer)
61 (widen)
62 (delete-other-windows)
63 (bury-buffer gnus-Article-buffer)
64 (funcall gnus-mail-reply-method yank))
65
66 (defun gnus-Subject-mail-reply-with-original ()
67 "Reply mail to news author with original article."
68 (interactive)
69 (gnus-Subject-mail-reply t))
70
71 (defun gnus-Subject-mail-other-window ()
72 "Compose mail in other window.
73 Customize the variable `gnus-mail-other-window-method' to use another mailer."
74 (interactive)
75 (gnus-Subject-select-article)
76 (switch-to-buffer gnus-Article-buffer)
77 (widen)
78 (delete-other-windows)
79 (bury-buffer gnus-Article-buffer)
80 (funcall gnus-mail-other-window-method))
81
82 \f
83 ;;; Send mail using sendmail mail mode.
84
85 (defun gnus-mail-reply-using-mail (&optional yank)
86 "Compose reply mail using mail.
87 Optional argument YANK means yank original article."
88 (news-mail-reply)
89 (gnus-overload-functions)
90 (if yank
91 (let ((last (point)))
92 (goto-char (point-max))
93 (mail-yank-original nil)
94 (goto-char last)
95 )))
96
97 (defun gnus-mail-other-window-using-mail ()
98 "Compose mail other window using mail."
99 (news-mail-other-window)
100 (gnus-overload-functions))
101
102 \f
103 ;;; Send mail using mh-e.
104
105 ;; The following mh-e interface is all cooperative works of
106 ;; tanaka@flab.fujitsu.CO.JP (TANAKA Hiroshi), kawabe@sra.CO.JP
107 ;; (Yoshikatsu Kawabe), and shingu@casund.cpr.canon.co.jp (Toshiaki
108 ;; SHINGU).
109
110 (defun gnus-mail-reply-using-mhe (&optional yank)
111 "Compose reply mail using mh-e.
112 Optional argument YANK means yank original article.
113 The command \\[mh-yank-cur-msg] yanks the original message into current buffer."
114 ;; First of all, prepare mhe mail buffer.
115 (let (from cc subject date to reply-to (buffer (current-buffer)))
116 (save-restriction
117 (gnus-Article-show-all-headers) ;I don't think this is really needed.
118 (setq from (gnus-fetch-field "from")
119 subject (let ((subject (gnus-fetch-field "subject")))
120 (if (and subject
121 (not (string-match "^[Rr][Ee]:.+$" subject)))
122 (concat "Re: " subject) subject))
123 reply-to (gnus-fetch-field "reply-to")
124 cc (gnus-fetch-field "cc")
125 date (gnus-fetch-field "date"))
126 (setq mh-show-buffer buffer)
127 (setq to (or reply-to from))
128 (mh-find-path)
129 (mh-send to (or cc "") subject)
130 (save-excursion
131 (mh-insert-fields
132 "In-reply-to:"
133 (concat
134 (substring from 0 (string-match " *at \\| *@ \\| *(\\| *<" from))
135 "'s message of " date)))
136 (setq mh-sent-from-folder buffer)
137 (setq mh-sent-from-msg 1)
138 ))
139 ;; Then, yank original article if requested.
140 (if yank
141 (let ((last (point)))
142 (mh-yank-cur-msg)
143 (goto-char last)
144 )))
145
146 (defun gnus-mail-other-window-using-mhe ()
147 "Compose mail other window using MH-E Mail."
148 (let ((to (read-string "To: "))
149 (cc (read-string "Cc: "))
150 (subject (read-string "Subject: " (gnus-fetch-field "subject"))))
151 (gnus-Article-show-all-headers) ;I don't think this is really needed.
152 (setq mh-show-buffer (current-buffer))
153 (mh-find-path)
154 (mh-send-other-window to cc subject)
155 (setq mh-sent-from-folder (current-buffer))
156 (setq mh-sent-from-msg 1)))
157
158 (provide 'gnusmail)
159
160 ;;; gnusmail.el ends here