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