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