25e91493a58f10de00fbe9c286e8d3b518ed675d
[gnus] / lisp / gnus-mh.el
1 ;;; gnus-mh.el --- mh-e interface for Gnus
2 ;; Copyright (C) 1994,95 Free Software Foundation, Inc.
3
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;;      Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
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)
13 ;; any later version.
14
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.
19
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.
23
24 ;;; Commentary:
25
26 ;;; Send mail using mh-e.
27
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
31 ;; SHINGU).
32
33 ;;; Code:
34
35 (require 'mh-e)
36 (require 'mh-comp)
37 (require 'gnus)
38 (require 'gnus-msg)
39
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."
46   (interactive "P")
47   (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
48     (gnus-summary-save-article arg)))
49
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.
54   (mh-find-path)
55   (let ((folder
56          (cond ((and (eq folder 'default)
57                      gnus-newsgroup-last-folder)
58                 gnus-newsgroup-last-folder)
59                (folder folder)
60                (t (mh-prompt-for-folder 
61                    "Save article in"
62                    (funcall gnus-folder-save-name gnus-newsgroup-name
63                             gnus-current-headers gnus-newsgroup-last-folder)
64                    t))))
65         (errbuf (get-buffer-create " *Gnus rcvstore*")))
66     (gnus-eval-in-buffer-window 
67      gnus-article-buffer
68      (save-restriction
69        (widen)
70        (unwind-protect
71            (call-process-region (point-min) (point-max)
72                                 (expand-file-name "rcvstore" mh-lib)
73                                 nil errbuf nil folder)
74          (set-buffer errbuf)
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)))
80
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)
84     (mh-find-path)
85     (mh-send-sub (or to "") (or cc "") (or subject "(None)") 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 mh-previous-window-config config)))
91
92 (defun gnus-Folder-save-name (newsgroup headers &optional last-folder)
93   "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
94 If variable `gnus-use-long-file-name' is nil, it is +News.group.
95 Otherwise, it is like +news/group."
96   (or last-folder
97       (concat "+"
98               (if gnus-use-long-file-name
99                   (gnus-capitalize-newsgroup newsgroup)
100                 (gnus-newsgroup-directory-form newsgroup)))))
101
102 (defun gnus-folder-save-name (newsgroup headers &optional last-folder)
103   "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
104 If variable `gnus-use-long-file-name' is nil, it is +news.group.
105 Otherwise, it is like +news/group."
106   (or last-folder
107       (concat "+"
108               (if gnus-use-long-file-name
109                   newsgroup
110                 (gnus-newsgroup-directory-form newsgroup)))))
111
112 ;;; gnus-mh.el ends here