Merge branch 'master' into comment-cache
[emacs.git] / lisp / gnus / gnus-mh.el
blob502b295cd60b1e01fd1c50111d8d3b64b4ae8a0b
1 ;;; gnus-mh.el --- mh-e interface for Gnus
3 ;; Copyright (C) 1994-2017 Free Software Foundation, Inc.
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
6 ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news
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 3 of the License, or
14 ;; (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
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
31 ;; SHINGU).
33 ;;; Code:
35 (require 'gnus)
36 (require 'mh-e)
37 (require 'mh-comp)
38 (require 'gnus-msg)
39 (require 'gnus-sum)
41 (defvar mh-lib-progs)
43 (defcustom gnus-rcvstore-options nil
44 "Options that are passed to rcvstore, or nil.
45 These are used when saving articles to an MH folder."
46 :version "26.1"
47 :group 'gnus-article
48 :type '(repeat string))
50 (defun gnus-summary-save-article-folder (&optional arg)
51 "Append the current article to an mh folder.
52 If N is a positive number, save the N next articles.
53 If N is a negative number, save the N previous articles.
54 If N is nil and any articles have been marked with the process mark,
55 save those articles instead."
56 (interactive "P")
57 (require 'gnus-art)
58 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
59 (gnus-summary-save-article arg)))
61 (defun gnus-summary-save-in-folder (&optional folder)
62 "Save this article to MH folder (using `rcvstore' in MH library).
63 Optional argument FOLDER specifies folder name."
64 ;; Thanks to yuki@flab.Fujitsu.JUNET and ohm@kaba.junet.
65 (mh-find-path)
66 (let ((folder
67 (cond ((and (eq folder 'default)
68 gnus-newsgroup-last-folder)
69 gnus-newsgroup-last-folder)
70 (folder folder)
71 (t (mh-prompt-for-folder
72 "Save article in"
73 (funcall gnus-folder-save-name gnus-newsgroup-name
74 gnus-current-headers gnus-newsgroup-last-folder)
75 t))))
76 (errbuf (gnus-get-buffer-create " *Gnus rcvstore*"))
77 ;; Find the rcvstore program.
78 (exec-path (cond
79 ((and (boundp 'mh-lib-progs) mh-lib-progs)
80 (cons mh-lib-progs exec-path))
81 (mh-lib (cons mh-lib exec-path))
82 (t exec-path))))
83 (with-current-buffer gnus-original-article-buffer
84 (save-restriction
85 (widen)
86 (unwind-protect
87 (apply
88 #'call-process-region
89 (point-min) (point-max) "rcvstore" nil errbuf nil folder
90 gnus-rcvstore-options)
91 (set-buffer errbuf)
92 (if (zerop (buffer-size))
93 (message "Article saved in folder: %s" folder)
94 (message "%s" (buffer-string)))
95 (kill-buffer errbuf))))
96 (setq gnus-newsgroup-last-folder folder)))
98 (defun gnus-Folder-save-name (newsgroup headers &optional last-folder)
99 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
100 If variable `gnus-use-long-file-name' is nil, it is +News.group.
101 Otherwise, it is like +news/group."
102 (or last-folder
103 (concat "+"
104 (if gnus-use-long-file-name
105 (gnus-capitalize-newsgroup newsgroup)
106 (gnus-newsgroup-directory-form newsgroup)))))
108 (defun gnus-folder-save-name (newsgroup headers &optional last-folder)
109 "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
110 If variable `gnus-use-long-file-name' is nil, it is +news.group.
111 Otherwise, it is like +news/group."
112 (or last-folder
113 (concat "+"
114 (if gnus-use-long-file-name
115 newsgroup
116 (gnus-newsgroup-directory-form newsgroup)))))
118 (provide 'gnus-mh)
120 ;;; gnus-mh.el ends here