1 ;;; gnus-mh.el --- mh-e interface for Gnus
3 ;; Copyright (C) 1994,95 Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;;; Send mail using mh-e.
30 ;; The following mh-e interface is all cooperative works of
31 ;; tanaka@flab.fujitsu.CO.JP (TANAKA Hiroshi), kawabe@sra.CO.JP
32 ;; (Yoshikatsu Kawabe), and shingu@casund.cpr.canon.co.jp (Toshiaki
42 (defun gnus-summary-save-article-folder (&optional arg
)
43 "Append the current article to an mh folder.
44 If N is a positive number, save the N next articles.
45 If N is a negative number, save the N previous articles.
46 If N is nil and any articles have been marked with the process mark,
47 save those articles instead."
49 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder
))
50 (gnus-summary-save-article arg
)))
52 (defun gnus-summary-save-in-folder (&optional folder
)
53 "Save this article to MH folder (using `rcvstore' in MH library).
54 Optional argument FOLDER specifies folder name."
55 ;; Thanks to yuki@flab.Fujitsu.JUNET and ohm@kaba.junet.
61 (funcall gnus-folder-save-name gnus-newsgroup-name
62 gnus-current-headers gnus-newsgroup-last-folder
)
64 (errbuf (get-buffer-create " *Gnus rcvstore*")))
65 (gnus-eval-in-buffer-window
70 (call-process-region (point-min) (point-max)
71 (expand-file-name "rcvstore" mh-lib
)
72 nil errbuf nil folder
)
74 (if (zerop (buffer-size))
75 (message "Article saved in folder: %s" folder
)
76 (message "%s" (buffer-string)))
77 (kill-buffer errbuf
))))
78 (setq gnus-newsgroup-last-folder folder
)))
80 (defun gnus-mail-reply-using-mhe (&optional yank
)
81 "Compose reply mail using mh-e.
82 Optional argument YANK means yank original article.
83 The command \\[mh-yank-cur-msg] yank the original message into current buffer."
84 (let (from cc subject date to reply-to to-userid orig-to
86 (config (current-window-configuration))
88 (pop-to-buffer gnus-article-buffer
)
89 (setq buffer
(current-buffer))
92 (or gnus-user-login-name
; we need this
93 (setq gnus-user-login-name
(or (getenv "USER")
96 (gnus-article-show-all-headers);; so colors are happy
97 ;; lots of junk to avoid mh-send deleting other windows
98 (setq from
(or (gnus-fetch-field "from") "")
99 subject
(let ((subject (or (gnus-fetch-field "subject")
102 (not (string-match "^[Rr][Ee]:.+$" subject
)))
103 (concat "Re: " subject
) subject
))
104 reply-to
(gnus-fetch-field "reply-to")
105 cc
(gnus-fetch-field "cc")
106 orig-to
(or (gnus-fetch-field "to") "")
107 date
(gnus-fetch-field "date")
108 references
(gnus-fetch-field "references")
109 message-id
(gnus-fetch-field "message-id"))
110 (setq to
(or reply-to from
))
111 (setq to-userid
(mail-strip-quoted-names orig-to
))
112 (if (or (string-match "," orig-to
)
113 (not (string-match (substring to-userid
0
114 (string-match "@" to-userid
))
115 gnus-user-login-name
)))
116 (setq cc
(concat (if cc
(concat cc
", ") "") orig-to
)))
117 ;; mh-yank-cur-msg needs to have mh-show-buffer set in the
119 (setq mh-show-buffer buffer
)))
122 (mh-send-sub (or to
"") (or cc
"")
123 (or subject
"(None)") config
);; Erik Selberg 1/23/94
125 (let ((draft (current-buffer))
126 (gnus-mail-buffer (current-buffer))
129 (gnus-configure-windows 'reply
'force
)
130 (gnus-configure-windows 'reply-yank
'force
))
131 (setq mail-buf gnus-mail-buffer
)
132 (pop-to-buffer mail-buf
);; always in the display, so won't have window probs
133 (switch-to-buffer draft
))
135 ;; (mh-send to (or cc "") subject);; shouldn't use according to mhe
137 ;; note - current buffer is now draft!
142 (substring from
0 (string-match " *at \\| *@ \\| *(\\| *<" from
))
143 "'s message of " date
))
144 (nnheader-insert-references references message-id
))
146 ;; need this for mh-yank-cur-msg
147 (setq mh-sent-from-folder buffer
)
148 (setq mh-sent-from-msg
1)
149 (setq mh-show-buffer buffer
)
150 (setq mh-previous-window-config config
))
152 ;; Then, yank original article if requested.
154 (let ((last (point)))
158 (run-hooks 'gnus-mail-hook
))
161 ;; gnus-mail-forward-using-mhe is contributed by Jun-ichiro Itoh
162 ;; <itojun@ingram.mt.cs.keio.ac.jp>
164 (defun gnus-mail-forward-using-mhe (&optional buffer
)
165 "Forward the current message to another user using mh-e."
166 ;; First of all, prepare mhe mail buffer.
167 (let* ((to (read-string "To: "))
168 (cc (read-string "Cc: "))
169 (buffer (or buffer gnus-article-buffer
))
170 (config (current-window-configuration));; need to add this - erik
171 (subject (gnus-forward-make-subject buffer
)))
172 (setq mh-show-buffer buffer
)
174 (mh-send-sub to
(or cc
"") (or subject
"(None)") config
);; Erik Selberg 1/23/94
175 (let ((draft (current-buffer))
176 (gnus-mail-buffer (current-buffer))
178 (gnus-configure-windows 'reply-yank
'force
)
179 (setq mail-buf
(eval (cdr (assq 'mail gnus-window-to-buffer
))))
180 (pop-to-buffer mail-buf
);; always in the display, so won't have window probs
181 (switch-to-buffer draft
)
184 (goto-char (point-max))
185 (insert "\n------- Forwarded Message\n\n")
186 (insert-buffer buffer
)
187 (goto-char (point-max))
188 (insert "\n------- End of Forwarded Message\n")
189 (setq mh-sent-from-folder buffer
)
190 (setq mh-sent-from-msg
1)
191 (setq mh-previous-window-config config
)
192 (run-hooks 'gnus-mail-hook
)
195 (defun gnus-mail-other-window-using-mhe ()
196 "Compose mail other window using mh-e."
197 (let ((to (read-string "To: "))
198 (cc (read-string "Cc: "))
199 (subject (read-string "Subject: ")))
200 (gnus-article-show-all-headers) ;I don't think this is really needed.
201 (setq mh-show-buffer
(current-buffer))
203 (mh-send-other-window to cc subject
)
204 (setq mh-sent-from-folder
(current-buffer))
205 (setq mh-sent-from-msg
1)
206 (run-hooks 'gnus-mail-hook
)))
208 (defun gnus-Folder-save-name (newsgroup headers
&optional last-folder
)
209 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
210 If variable `gnus-use-long-file-name' is nil, it is +News.group.
211 Otherwise, it is like +news/group."
214 (if gnus-use-long-file-name
215 (gnus-capitalize-newsgroup newsgroup
)
216 (gnus-newsgroup-directory-form newsgroup
)))))
218 (defun gnus-folder-save-name (newsgroup headers
&optional last-folder
)
219 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
220 If variable `gnus-use-long-file-name' is nil, it is +news.group.
221 Otherwise, it is like +news/group."
224 (if gnus-use-long-file-name
226 (gnus-newsgroup-directory-form newsgroup
)))))
228 ;;; gnus-mh.el ends here