gnus-mh.el 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. ;;; gnus-mh.el --- mh-e interface for Gnus
  2. ;; Copyright (C) 1994-2015 Free Software Foundation, Inc.
  3. ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
  4. ;; Lars Magne Ingebrigtsen <larsi@gnus.org>
  5. ;; Keywords: news
  6. ;; This file is part of GNU Emacs.
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;;; Send mail using mh-e.
  19. ;; The following mh-e interface is all cooperative works of
  20. ;; tanaka@flab.fujitsu.CO.JP (TANAKA Hiroshi), kawabe@sra.CO.JP
  21. ;; (Yoshikatsu Kawabe), and shingu@casund.cpr.canon.co.jp (Toshiaki
  22. ;; SHINGU).
  23. ;;; Code:
  24. (require 'gnus)
  25. (require 'mh-e)
  26. (require 'mh-comp)
  27. (require 'gnus-msg)
  28. (require 'gnus-sum)
  29. (defvar mh-lib-progs)
  30. (defun gnus-summary-save-article-folder (&optional arg)
  31. "Append the current article to an mh folder.
  32. If N is a positive number, save the N next articles.
  33. If N is a negative number, save the N previous articles.
  34. If N is nil and any articles have been marked with the process mark,
  35. save those articles instead."
  36. (interactive "P")
  37. (require 'gnus-art)
  38. (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
  39. (gnus-summary-save-article arg)))
  40. (defun gnus-summary-save-in-folder (&optional folder)
  41. "Save this article to MH folder (using `rcvstore' in MH library).
  42. Optional argument FOLDER specifies folder name."
  43. ;; Thanks to yuki@flab.Fujitsu.JUNET and ohm@kaba.junet.
  44. (mh-find-path)
  45. (let ((folder
  46. (cond ((and (eq folder 'default)
  47. gnus-newsgroup-last-folder)
  48. gnus-newsgroup-last-folder)
  49. (folder folder)
  50. (t (mh-prompt-for-folder
  51. "Save article in"
  52. (funcall gnus-folder-save-name gnus-newsgroup-name
  53. gnus-current-headers gnus-newsgroup-last-folder)
  54. t))))
  55. (errbuf (gnus-get-buffer-create " *Gnus rcvstore*"))
  56. ;; Find the rcvstore program.
  57. (exec-path (cond
  58. ((and (boundp 'mh-lib-progs) mh-lib-progs)
  59. (cons mh-lib-progs exec-path))
  60. (mh-lib (cons mh-lib exec-path))
  61. (t exec-path))))
  62. (with-current-buffer gnus-original-article-buffer
  63. (save-restriction
  64. (widen)
  65. (unwind-protect
  66. (call-process-region
  67. (point-min) (point-max) "rcvstore" nil errbuf nil folder)
  68. (set-buffer errbuf)
  69. (if (zerop (buffer-size))
  70. (message "Article saved in folder: %s" folder)
  71. (message "%s" (buffer-string)))
  72. (kill-buffer errbuf))))
  73. (setq gnus-newsgroup-last-folder folder)))
  74. (defun gnus-Folder-save-name (newsgroup headers &optional last-folder)
  75. "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
  76. If variable `gnus-use-long-file-name' is nil, it is +News.group.
  77. Otherwise, it is like +news/group."
  78. (or last-folder
  79. (concat "+"
  80. (if gnus-use-long-file-name
  81. (gnus-capitalize-newsgroup newsgroup)
  82. (gnus-newsgroup-directory-form newsgroup)))))
  83. (defun gnus-folder-save-name (newsgroup headers &optional last-folder)
  84. "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.
  85. If variable `gnus-use-long-file-name' is nil, it is +news.group.
  86. Otherwise, it is like +news/group."
  87. (or last-folder
  88. (concat "+"
  89. (if gnus-use-long-file-name
  90. newsgroup
  91. (gnus-newsgroup-directory-form newsgroup)))))
  92. (provide 'gnus-mh)
  93. ;;; gnus-mh.el ends here