*** empty log message ***
[gnus] / lisp / gnus-mh.el
1 ;;; gnus-mh.el --- mh-e interface for Gnus
2 ;; Copyright (C) 1994,95,96,97 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 the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;;; Send mail using mh-e.
28
29 ;; The following mh-e interface is all cooperative works of
30 ;; tanaka@flab.fujitsu.CO.JP (TANAKA Hiroshi), kawabe@sra.CO.JP
31 ;; (Yoshikatsu Kawabe), and shingu@casund.cpr.canon.co.jp (Toshiaki
32 ;; SHINGU).
33
34 ;;; Code:
35
36 (require 'gnus)
37 (require 'mh-e)
38 (require 'mh-comp)
39 (require 'gnus-msg)
40 (require 'gnus-sum)
41
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."
48   (interactive "P")
49   (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
50     (gnus-summary-save-article arg)))
51
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.
56   (mh-find-path)
57   (let ((folder
58          (gnus-read-save-file-name
59                   "Save %s in file:" folder
60                   gnus-folder-save-name gnus-newsgroup-name
61                   gnus-current-headers 'gnus-newsgroup-last-folder))
62         (errbuf (get-buffer-create " *Gnus rcvstore*"))
63         ;; Find the rcvstore program.
64         (exec-path (if mh-lib (cons mh-lib exec-path) exec-path)))
65     (gnus-eval-in-buffer-window gnus-original-article-buffer
66       (save-restriction
67         (widen)
68         (unwind-protect
69             (call-process-region
70              (point-min) (point-max) "rcvstore" nil errbuf nil folder)
71           (set-buffer errbuf)
72           (if (zerop (buffer-size))
73               (message "Article saved in folder: %s" folder)
74             (message "%s" (buffer-string)))
75           (kill-buffer errbuf))))
76     (setq gnus-newsgroup-last-folder folder)))
77
78 (defun gnus-Folder-save-name (newsgroup headers &optional last-folder)
79   "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
80 If variable `gnus-use-long-file-name' is nil, it is +News.group.
81 Otherwise, it is like +news/group."
82   (or last-folder
83       (concat "+"
84               (if gnus-use-long-file-name
85                   (gnus-capitalize-newsgroup newsgroup)
86                 (gnus-newsgroup-directory-form newsgroup)))))
87
88 (defun gnus-folder-save-name (newsgroup headers &optional last-folder)
89   "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
90 If variable `gnus-use-long-file-name' is nil, it is +news.group.
91 Otherwise, it is like +news/group."
92   (or last-folder
93       (concat "+"
94               (if gnus-use-long-file-name
95                   newsgroup
96                 (gnus-newsgroup-directory-form newsgroup)))))
97
98 (provide 'gnus-mh)
99
100 ;;; gnus-mh.el ends here