1 ;;; gnus-mh: 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
39 (defun gnus-summary-save-in-folder (&optional folder)
40 "Save this article to MH folder (using `rcvstore' in MH library).
41 Optional argument FOLDER specifies folder name."
42 ;; Thanks to yuki@flab.Fujitsu.JUNET and ohm@kaba.junet.
48 (funcall gnus-folder-save-name gnus-newsgroup-name
49 gnus-current-headers gnus-newsgroup-last-folder)
51 (errbuf (get-buffer-create " *Gnus rcvstore*")))
52 (gnus-eval-in-buffer-window
57 (call-process-region (point-min) (point-max)
58 (expand-file-name "rcvstore" mh-lib)
59 nil errbuf nil folder)
61 (if (zerop (buffer-size))
62 (message "Article saved in folder: %s" folder)
63 (message "%s" (buffer-string)))
64 (kill-buffer errbuf))))
65 (setq gnus-newsgroup-last-folder folder)))
67 (defun gnus-mail-reply-using-mhe (&optional yank)
68 "Compose reply mail using mh-e.
69 Optional argument YANK means yank original article.
70 The command \\[mh-yank-cur-msg] yank the original message into current buffer."
71 (let (from cc subject date to reply-to to-userid orig-to
72 (config (current-window-configuration))
74 (pop-to-buffer gnus-article-buffer)
75 (setq buffer (current-buffer))
78 (or gnus-user-login-name ; we need this
79 (setq gnus-user-login-name (or (getenv "USER")
82 (gnus-article-show-all-headers) ;; so colors are happy
83 ;; lots of junk to avoid mh-send deleting other windows
84 (setq from (gnus-fetch-field "from")
85 subject (let ((subject (or (gnus-fetch-field "subject")
88 (not (string-match "^[Rr][Ee]:.+$" subject)))
89 (concat "Re: " subject) subject))
90 reply-to (gnus-fetch-field "reply-to")
91 cc (gnus-fetch-field "cc")
92 orig-to (or (gnus-fetch-field "to") "")
93 date (gnus-fetch-field "date"))
94 (setq to (or reply-to from))
95 (setq to-userid (mail-strip-quoted-names orig-to))
96 (if (or (string-match "," orig-to)
97 (not (string-match (substring to-userid 0 (string-match "@" to-userid))
98 gnus-user-login-name)))
99 (setq cc (concat (if cc (concat cc ", ") "") orig-to))
101 ;; mh-yank-cur-msg needs to have mh-show-buffer set in the
103 (setq mh-show-buffer buffer)
104 )) ;; save excursion/restriction
107 (mh-send-sub to (or cc "") (or subject "(None)") config) ;; Erik Selberg 1/23/94
109 (let ((draft (current-buffer))
112 (gnus-configure-windows 'reply)
113 (gnus-configure-windows 'reply-yank))
114 (setq mail-buf (cdr (assq 'mail gnus-window-to-buffer)))
115 (pop-to-buffer mail-buf) ;; always in the display, so won't have window probs
116 (switch-to-buffer draft)
117 (kill-buffer mail-buf) ;; mh-e don't use it!
120 ;; (mh-send to (or cc "") subject);; shouldn't use according to mhe
122 ;; note - current buffer is now draft!
127 (substring from 0 (string-match " *at \\| *@ \\| *(\\| *<" from))
128 "'s message of " date)))
130 ;; need this for mh-yank-cur-msg
131 (setq mh-sent-from-folder buffer)
132 (setq mh-sent-from-msg 1)
133 (setq mh-show-buffer buffer)
134 (setq mh-previous-window-config config)
137 ;; Then, yank original article if requested.
139 (let ((last (point)))
144 ;; gnus-mail-forward-using-mhe is contributed by Jun-ichiro Itoh
145 ;; <itojun@ingram.mt.cs.keio.ac.jp>
147 (defun gnus-mail-forward-using-mhe ()
148 "Forward the current message to another user using mh-e."
149 ;; First of all, prepare mhe mail buffer.
150 (let ((to (read-string "To: "))
151 (cc (read-string "Cc: "))
152 (buffer (current-buffer))
154 (config (current-window-configuration))) ;; need to add this - erik
155 ;;(gnus-article-show-all-headers)
157 (concat "[" gnus-newsgroup-name "] "
158 ;;(mail-strip-quoted-names (gnus-fetch-field "From")) ": "
159 (or (gnus-fetch-field "subject") "")))
160 (setq mh-show-buffer buffer)
162 (mh-send-sub to (or cc "") (or subject "(None)") config) ;; Erik Selberg 1/23/94
163 (let ((draft (current-buffer))
165 (gnus-configure-windows 'reply-yank)
166 (setq mail-buf (cdr (assq 'mail gnus-window-to-buffer)))
167 (pop-to-buffer mail-buf) ;; always in the display, so won't have window probs
168 (switch-to-buffer draft)
169 (kill-buffer mail-buf) ;; mh-e don't use it!
172 (goto-char (point-max))
173 (insert "\n------- Forwarded Message\n\n")
174 (insert-buffer buffer)
175 (goto-char (point-max))
176 (insert "\n------- End of Forwarded Message\n")
177 (setq mh-sent-from-folder buffer)
178 (setq mh-sent-from-msg 1)
179 (setq mh-previous-window-config config)
182 (defun gnus-mail-other-window-using-mhe ()
183 "Compose mail other window using mh-e."
184 (let ((to (read-string "To: "))
185 (cc (read-string "Cc: "))
186 (subject (read-string "Subject: ")))
187 (gnus-article-show-all-headers) ;I don't think this is really needed.
188 (setq mh-show-buffer (current-buffer))
190 (mh-send-other-window to cc subject)
191 (setq mh-sent-from-folder (current-buffer))
192 (setq mh-sent-from-msg 1)))
194 (defun gnus-Folder-save-name (newsgroup headers &optional last-folder)
195 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
196 If variable `gnus-use-long-file-name' is nil, it is +News.group.
197 Otherwise, it is like +news/group."
200 (if gnus-use-long-file-name
201 (gnus-capitalize-newsgroup newsgroup)
202 (gnus-newsgroup-directory-form newsgroup)))))
204 (defun gnus-folder-save-name (newsgroup headers &optional last-folder)
205 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
206 If variable `gnus-use-long-file-name' is nil, it is +news.group.
207 Otherwise, it is like +news/group."
210 (if gnus-use-long-file-name
212 (gnus-newsgroup-directory-form newsgroup)))))
214 ;;; gnus-mh.el ends here