1 ;;; gnus-mh.el --- mh-e interface for Gnus
2 ;; Copyright (C) 1994,95 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
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)
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.
26 ;;; Send mail using mh-e.
28 ;; The following mh-e interface is all cooperative works of
29 ;; tanaka@flab.fujitsu.CO.JP (TANAKA Hiroshi), kawabe@sra.CO.JP
30 ;; (Yoshikatsu Kawabe), and shingu@casund.cpr.canon.co.jp (Toshiaki
40 (defun gnus-summary-save-article-folder (arg)
41 "Append the current article to an mh folder.
42 If N is a positive number, save the N next articles.
43 If N is a negative number, save the N previous articles.
44 If N is nil and any articles have been marked with the process mark,
45 save those articles instead."
47 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
48 (gnus-summary-save-article arg)))
50 (defun gnus-summary-save-in-folder (&optional folder)
51 "Save this article to MH folder (using `rcvstore' in MH library).
52 Optional argument FOLDER specifies folder name."
53 ;; Thanks to yuki@flab.Fujitsu.JUNET and ohm@kaba.junet.
59 (funcall gnus-folder-save-name gnus-newsgroup-name
60 gnus-current-headers gnus-newsgroup-last-folder)
62 (errbuf (get-buffer-create " *Gnus rcvstore*")))
63 (gnus-eval-in-buffer-window
68 (call-process-region (point-min) (point-max)
69 (expand-file-name "rcvstore" mh-lib)
70 nil errbuf nil folder)
72 (if (zerop (buffer-size))
73 (message "Article saved in folder: %s" folder)
74 (message "%s" (buffer-string)))
75 (kill-buffer errbuf))))
76 (setq gnus-newsgroup-last-folder folder)))
78 (defun gnus-mail-reply-using-mhe (&optional yank)
79 "Compose reply mail using mh-e.
80 Optional argument YANK means yank original article.
81 The command \\[mh-yank-cur-msg] yank the original message into current buffer."
82 (let (from cc subject date to reply-to to-userid orig-to
83 (config (current-window-configuration))
85 (pop-to-buffer gnus-article-buffer)
86 (setq buffer (current-buffer))
89 (or gnus-user-login-name ; we need this
90 (setq gnus-user-login-name (or (getenv "USER")
93 (gnus-article-show-all-headers) ;; so colors are happy
94 ;; lots of junk to avoid mh-send deleting other windows
95 (setq from (gnus-fetch-field "from")
96 subject (let ((subject (or (gnus-fetch-field "subject")
99 (not (string-match "^[Rr][Ee]:.+$" subject)))
100 (concat "Re: " subject) subject))
101 reply-to (gnus-fetch-field "reply-to")
102 cc (gnus-fetch-field "cc")
103 orig-to (or (gnus-fetch-field "to") "")
104 date (gnus-fetch-field "date"))
105 (setq to (or reply-to from))
106 (setq to-userid (mail-strip-quoted-names orig-to))
107 (if (or (string-match "," orig-to)
108 (not (string-match (substring to-userid 0 (string-match "@" to-userid))
109 gnus-user-login-name)))
110 (setq cc (concat (if cc (concat cc ", ") "") orig-to))
112 ;; mh-yank-cur-msg needs to have mh-show-buffer set in the
114 (setq mh-show-buffer buffer)
115 )) ;; save excursion/restriction
118 (mh-send-sub to (or cc "") (or subject "(None)") config) ;; Erik Selberg 1/23/94
120 (let ((draft (current-buffer))
123 (gnus-configure-windows 'reply)
124 (gnus-configure-windows 'reply-yank))
125 (setq mail-buf (cdr (assq 'mail gnus-window-to-buffer)))
126 (pop-to-buffer mail-buf) ;; always in the display, so won't have window probs
127 (switch-to-buffer draft)
128 (kill-buffer mail-buf) ;; mh-e don't use it!
131 ;; (mh-send to (or cc "") subject);; shouldn't use according to mhe
133 ;; note - current buffer is now draft!
138 (substring from 0 (string-match " *at \\| *@ \\| *(\\| *<" from))
139 "'s message of " date)))
141 ;; need this for mh-yank-cur-msg
142 (setq mh-sent-from-folder buffer)
143 (setq mh-sent-from-msg 1)
144 (setq mh-show-buffer buffer)
145 (setq mh-previous-window-config config)
148 ;; Then, yank original article if requested.
150 (let ((last (point)))
155 ;; gnus-mail-forward-using-mhe is contributed by Jun-ichiro Itoh
156 ;; <itojun@ingram.mt.cs.keio.ac.jp>
158 (defun gnus-mail-forward-using-mhe (&optional buffer)
159 "Forward the current message to another user using mh-e."
160 ;; First of all, prepare mhe mail buffer.
161 (let* ((to (read-string "To: "))
162 (cc (read-string "Cc: "))
163 (buffer (or buffer gnus-article-buffer))
164 (config (current-window-configuration)) ;; need to add this - erik
165 (subject (gnus-forward-make-subject buffer)))
166 (setq mh-show-buffer buffer)
168 (mh-send-sub to (or cc "") (or subject "(None)") config) ;; Erik Selberg 1/23/94
169 (let ((draft (current-buffer))
171 (gnus-configure-windows 'reply-yank)
172 (setq mail-buf (cdr (assq 'mail gnus-window-to-buffer)))
173 (pop-to-buffer mail-buf) ;; always in the display, so won't have window probs
174 (switch-to-buffer draft)
175 (kill-buffer mail-buf) ;; mh-e don't use it!
178 (goto-char (point-max))
179 (insert "\n------- Forwarded Message\n\n")
180 (insert-buffer buffer)
181 (goto-char (point-max))
182 (insert "\n------- End of Forwarded Message\n")
183 (setq mh-sent-from-folder buffer)
184 (setq mh-sent-from-msg 1)
185 (setq mh-previous-window-config config)
188 (defun gnus-mail-other-window-using-mhe ()
189 "Compose mail other window using mh-e."
190 (let ((to (read-string "To: "))
191 (cc (read-string "Cc: "))
192 (subject (read-string "Subject: ")))
193 (gnus-article-show-all-headers) ;I don't think this is really needed.
194 (setq mh-show-buffer (current-buffer))
196 (mh-send-other-window to cc subject)
197 (setq mh-sent-from-folder (current-buffer))
198 (setq mh-sent-from-msg 1)))
200 (defun gnus-Folder-save-name (newsgroup headers &optional last-folder)
201 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
202 If variable `gnus-use-long-file-name' is nil, it is +News.group.
203 Otherwise, it is like +news/group."
206 (if gnus-use-long-file-name
207 (gnus-capitalize-newsgroup newsgroup)
208 (gnus-newsgroup-directory-form newsgroup)))))
210 (defun gnus-folder-save-name (newsgroup headers &optional last-folder)
211 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
212 If variable `gnus-use-long-file-name' is nil, it is +news.group.
213 Otherwise, it is like +news/group."
216 (if gnus-use-long-file-name
218 (gnus-newsgroup-directory-form newsgroup)))))
220 ;;; gnus-mh.el ends here