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 (&optional 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.
56 (cond ((and (eq folder 'default)
57 gnus-newsgroup-last-folder)
58 gnus-newsgroup-last-folder)
60 (t (mh-prompt-for-folder
62 (funcall gnus-folder-save-name gnus-newsgroup-name
63 gnus-current-headers gnus-newsgroup-last-folder)
65 (errbuf (get-buffer-create " *Gnus rcvstore*")))
66 (gnus-eval-in-buffer-window
67 gnus-original-article-buffer
71 (call-process-region (point-min) (point-max)
72 (expand-file-name "rcvstore" mh-lib)
73 nil errbuf nil folder)
75 (if (zerop (buffer-size))
76 (message "Article saved in folder: %s" folder)
77 (message "%s" (buffer-string)))
78 (kill-buffer errbuf))))
79 (setq gnus-newsgroup-last-folder folder)))
81 (defun gnus-mh-mail-setup (to subject in-reply-to cc replybuffer actions)
82 (let ((config (current-window-configuration)))
83 (setq mh-show-buffer gnus-article-copy)
85 (mh-send-sub (or to "") (or cc "") (or subject "") config)
86 (goto-char (point-min))
87 (and in-reply-to (insert "In-Reply-To: " in-reply-to "\n"))
88 (setq mh-sent-from-folder gnus-article-copy)
89 (setq mh-sent-from-msg 1)
90 (setq gnus-mail-buffer (buffer-name (current-buffer)))
91 (local-set-key "\C-c\C-c" 'gnus-mh-mail-send-and-exit)
92 (setq mh-previous-window-config config)))
94 (defun gnus-mh-mail-send-and-exit (&optional dont-send)
95 "Send the current mail and return to Gnus."
97 (let* ((reply gnus-article-reply)
98 (winconf gnus-prev-winconf)
99 (address-group gnus-add-to-address)
100 (to-address (and address-group
101 (mail-fetch-field "to"))))
102 (setq gnus-add-to-address nil)
103 (or dont-send (mh-send-letter))
105 ;; This mail group doesn't have a `to-address', so we add one
108 (gnus-group-add-parameter
109 address-group (cons 'to-address to-address)))
110 (if (get-buffer gnus-group-buffer)
112 (if (gnus-buffer-exists-p (car-safe reply))
114 (set-buffer (car reply))
116 (gnus-summary-mark-article-as-replied
118 (and winconf (set-window-configuration winconf))))))
120 (defun gnus-Folder-save-name (newsgroup headers &optional last-folder)
121 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
122 If variable `gnus-use-long-file-name' is nil, it is +News.group.
123 Otherwise, it is like +news/group."
126 (if gnus-use-long-file-name
127 (gnus-capitalize-newsgroup newsgroup)
128 (gnus-newsgroup-directory-form newsgroup)))))
130 (defun gnus-folder-save-name (newsgroup headers &optional last-folder)
131 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
132 If variable `gnus-use-long-file-name' is nil, it is +news.group.
133 Otherwise, it is like +news/group."
136 (if gnus-use-long-file-name
138 (gnus-newsgroup-directory-form newsgroup)))))
140 ;;; gnus-mh.el ends here