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 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 ;; First of all, prepare mhe mail buffer.
72 ;; Bug fix by Timo METZEMAKERS <metzemakers@labri.u-bordeaux.fr>.
73 (pop-to-buffer gnus-article-buffer)
74 (let (from cc subject date to reply-to (buffer (current-buffer)))
76 (gnus-article-show-all-headers) ;I don't think this is really needed.
77 (setq from (gnus-fetch-field "from")
78 subject (let ((subject (or (gnus-fetch-field "subject")
81 (not (string-match "^[Rr][Ee]:.+$" subject)))
82 (concat "Re: " subject) subject))
83 reply-to (gnus-fetch-field "reply-to")
84 cc (gnus-fetch-field "cc")
85 date (gnus-fetch-field "date"))
86 (setq mh-show-buffer buffer)
87 (setq to (or reply-to from))
89 (mh-send to (or cc "") subject)
94 (substring from 0 (string-match " *at \\| *@ \\| *(\\| *<" from))
95 "'s message of " date)))
96 (setq mh-sent-from-folder buffer)
97 (setq mh-sent-from-msg 1)
99 ;; Then, yank original article if requested.
101 (let ((last (point)))
106 ;; gnus-mail-forward-using-mhe is contributed by Jun-ichiro Itoh
107 ;; <itojun@ingram.mt.cs.keio.ac.jp>
109 (defun gnus-mail-forward-using-mhe ()
110 "Forward the current message to another user using mh-e."
111 ;; First of all, prepare mhe mail buffer.
112 (let ((to (read-string "To: "))
113 (cc (read-string "Cc: "))
114 (buffer (current-buffer))
116 ;;(gnus-article-show-all-headers)
118 (concat "[" gnus-newsgroup-name "] "
119 ;;(mail-strip-quoted-names (gnus-fetch-field "From")) ": "
120 (or (gnus-fetch-field "subject") "")))
121 (setq mh-show-buffer buffer)
123 (mh-send to (or cc "") subject)
125 (goto-char (point-max))
127 (insert "\n------- Forwarded Message\n\n")
128 (insert-buffer buffer)
129 (goto-char (point-max))
130 (insert "\n------- End of Forwarded Message\n")
132 (while (setq beg (next-single-property-change (point) 'invisible))
134 (delete-region beg (or (next-single-property-change
137 (setq mh-sent-from-folder buffer)
138 (setq mh-sent-from-msg 1))))
140 (defun gnus-mail-other-window-using-mhe ()
141 "Compose mail other window using mh-e."
142 (let ((to (read-string "To: "))
143 (cc (read-string "Cc: "))
144 (subject (read-string "Subject: ")))
145 (gnus-article-show-all-headers) ;I don't think this is really needed.
146 (setq mh-show-buffer (current-buffer))
148 (mh-send-other-window to cc subject)
149 (setq mh-sent-from-folder (current-buffer))
150 (setq mh-sent-from-msg 1)))
152 (defun gnus-Folder-save-name (newsgroup headers &optional last-folder)
153 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
154 If variable `gnus-use-long-file-name' is nil, it is +News.group.
155 Otherwise, it is like +news/group."
158 (if gnus-use-long-file-name
159 (gnus-capitalize-newsgroup newsgroup)
160 (gnus-newsgroup-directory-form newsgroup)))))
162 (defun gnus-folder-save-name (newsgroup headers &optional last-folder)
163 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
164 If variable `gnus-use-long-file-name' is nil, it is +news.group.
165 Otherwise, it is like +news/group."
168 (if gnus-use-long-file-name
170 (gnus-newsgroup-directory-form newsgroup)))))
172 ;;; gnus-mh.el ends here