X-Git-Url: http://cgit.sxemacs.org/?p=gnus;a=blobdiff_plain;f=lisp%2Fgnus-mh.el;h=21c61ddc2c9d6ba2992d7a8ffc9e9ca05a584423;hp=1965f3c38d2a9f4124ccced412de1c15569043f7;hb=829fe7e073a13eaf991e04e90b1e731b1ccce0c2;hpb=80b1b5678cd36bcd6d0a90ae94fec6538c983b5e diff --git a/lisp/gnus-mh.el b/lisp/gnus-mh.el index 1965f3c38..21c61ddc2 100644 --- a/lisp/gnus-mh.el +++ b/lisp/gnus-mh.el @@ -1,16 +1,17 @@ -;;; gnus-mh: mh-e interface for Gnus -;; Copyright (C) 1994,95 Free Software Foundation, Inc. +;;; gnus-mh.el --- mh-e interface for Gnus + +;; Copyright (C) 1994-2015 Free Software Foundation, Inc. ;; Author: Masanobu UMEDA -;; Lars Magne Ingebrigtsen +;; Lars Magne Ingebrigtsen ;; Keywords: news ;; This file is part of GNU Emacs. -;; GNU Emacs is free software; you can redistribute it and/or modify +;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 2, or (at your option) -;; any later version. +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -18,8 +19,7 @@ ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License -;; along with GNU Emacs; see the file COPYING. If not, write to -;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +;; along with GNU Emacs. If not, see . ;;; Commentary: @@ -32,9 +32,24 @@ ;;; Code: +(require 'gnus) (require 'mh-e) (require 'mh-comp) -(require 'gnus) +(require 'gnus-msg) +(require 'gnus-sum) + +(defvar mh-lib-progs) + +(defun gnus-summary-save-article-folder (&optional arg) + "Append the current article to an mh folder. +If N is a positive number, save the N next articles. +If N is a negative number, save the N previous articles. +If N is nil and any articles have been marked with the process mark, +save those articles instead." + (interactive "P") + (require 'gnus-art) + (let ((gnus-default-article-saver 'gnus-summary-save-in-folder)) + (gnus-summary-save-article arg))) (defun gnus-summary-save-in-folder (&optional folder) "Save this article to MH folder (using `rcvstore' in MH library). @@ -42,154 +57,34 @@ Optional argument FOLDER specifies folder name." ;; Thanks to yuki@flab.Fujitsu.JUNET and ohm@kaba.junet. (mh-find-path) (let ((folder - (or folder - (mh-prompt-for-folder - "Save article in" - (funcall gnus-folder-save-name gnus-newsgroup-name - gnus-current-headers gnus-newsgroup-last-folder) - t))) - (errbuf (get-buffer-create " *Gnus rcvstore*"))) - (gnus-eval-in-buffer-window - gnus-article-buffer - (save-restriction - (widen) - (unwind-protect - (call-process-region (point-min) (point-max) - (expand-file-name "rcvstore" mh-lib) - nil errbuf nil folder) - (set-buffer errbuf) - (if (zerop (buffer-size)) - (message "Article saved in folder: %s" folder) - (message "%s" (buffer-string))) - (kill-buffer errbuf)))) - (setq gnus-newsgroup-last-folder folder))) - -(defun gnus-mail-reply-using-mhe (&optional yank) - "Compose reply mail using mh-e. -Optional argument YANK means yank original article. -The command \\[mh-yank-cur-msg] yank the original message into current buffer." - (let (from cc subject date to reply-to to-userid orig-to - (config (current-window-configuration)) - buffer) - (pop-to-buffer gnus-article-buffer) - (setq buffer (current-buffer)) - (save-excursion + (cond ((and (eq folder 'default) + gnus-newsgroup-last-folder) + gnus-newsgroup-last-folder) + (folder folder) + (t (mh-prompt-for-folder + "Save article in" + (funcall gnus-folder-save-name gnus-newsgroup-name + gnus-current-headers gnus-newsgroup-last-folder) + t)))) + (errbuf (gnus-get-buffer-create " *Gnus rcvstore*")) + ;; Find the rcvstore program. + (exec-path (cond + ((and (boundp 'mh-lib-progs) mh-lib-progs) + (cons mh-lib-progs exec-path)) + (mh-lib (cons mh-lib exec-path)) + (t exec-path)))) + (with-current-buffer gnus-original-article-buffer (save-restriction - (or gnus-user-login-name ; we need this - (setq gnus-user-login-name (or (getenv "USER") - (getenv "LOGNAME")))) - - (gnus-article-show-all-headers) ;; so colors are happy - ;; lots of junk to avoid mh-send deleting other windows - (setq from (gnus-fetch-field "from") - subject (let ((subject (or (gnus-fetch-field "subject") - "(None)"))) - (if (and subject - (not (string-match "^[Rr][Ee]:.+$" subject))) - (concat "Re: " subject) subject)) - reply-to (gnus-fetch-field "reply-to") - cc (gnus-fetch-field "cc") - orig-to (or (gnus-fetch-field "to") "") - date (gnus-fetch-field "date")) - (setq to (or reply-to from)) - (setq to-userid (mail-strip-quoted-names orig-to)) - (if (or (string-match "," orig-to) - (not (string-match (substring to-userid 0 (string-match "@" to-userid)) - gnus-user-login-name))) - (setq cc (concat (if cc (concat cc ", ") "") orig-to)) - ) - ;; mh-yank-cur-msg needs to have mh-show-buffer set in the - ;; *Article* buffer - (setq mh-show-buffer buffer) - )) ;; save excursion/restriction - - (mh-find-path) - (mh-send-sub to (or cc "") (or subject "(None)") config) ;; Erik Selberg 1/23/94 - - (let ((draft (current-buffer)) - mail-buf) - (if (not yank) - (gnus-configure-windows 'reply) - (gnus-configure-windows 'reply-yank)) - (setq mail-buf (cdr (assq 'mail gnus-window-to-buffer))) - (pop-to-buffer mail-buf) ;; always in the display, so won't have window probs - (switch-to-buffer draft) - (kill-buffer mail-buf) ;; mh-e don't use it! - ) - - ;; (mh-send to (or cc "") subject);; shouldn't use according to mhe - - ;; note - current buffer is now draft! - (save-excursion - (mh-insert-fields - "In-reply-to:" - (concat - (substring from 0 (string-match " *at \\| *@ \\| *(\\| *<" from)) - "'s message of " date))) - - ;; need this for mh-yank-cur-msg - (setq mh-sent-from-folder buffer) - (setq mh-sent-from-msg 1) - (setq mh-show-buffer buffer) - (setq mh-previous-window-config config) - ) - - ;; Then, yank original article if requested. - (if yank - (let ((last (point))) - (mh-yank-cur-msg) - (goto-char last) - ))) - -;; gnus-mail-forward-using-mhe is contributed by Jun-ichiro Itoh -;; - -(defun gnus-mail-forward-using-mhe () - "Forward the current message to another user using mh-e." - ;; First of all, prepare mhe mail buffer. - (let ((to (read-string "To: ")) - (cc (read-string "Cc: ")) - (buffer (current-buffer)) - subject - (config (current-window-configuration))) ;; need to add this - erik - ;;(gnus-article-show-all-headers) - (setq subject - (concat "[" gnus-newsgroup-name "] " - ;;(mail-strip-quoted-names (gnus-fetch-field "From")) ": " - (or (gnus-fetch-field "subject") ""))) - (setq mh-show-buffer buffer) - (mh-find-path) - (mh-send-sub to (or cc "") (or subject "(None)") config) ;; Erik Selberg 1/23/94 - (let ((draft (current-buffer)) - mail-buf) - (gnus-configure-windows 'reply-yank) - (setq mail-buf (cdr (assq 'mail gnus-window-to-buffer))) - (pop-to-buffer mail-buf) ;; always in the display, so won't have window probs - (switch-to-buffer draft) - (kill-buffer mail-buf) ;; mh-e don't use it! - ) - (save-excursion - (goto-char (point-max)) - (insert "\n------- Forwarded Message\n\n") - (insert-buffer buffer) - (goto-char (point-max)) - (insert "\n------- End of Forwarded Message\n") - (setq mh-sent-from-folder buffer) - (setq mh-sent-from-msg 1) - (setq mh-previous-window-config config) - ))) - -(defun gnus-mail-other-window-using-mhe () - "Compose mail other window using mh-e." - (let ((to (read-string "To: ")) - (cc (read-string "Cc: ")) - (subject (read-string "Subject: "))) - (gnus-article-show-all-headers) ;I don't think this is really needed. - (setq mh-show-buffer (current-buffer)) - (mh-find-path) - (mh-send-other-window to cc subject) - (setq mh-sent-from-folder (current-buffer)) - (setq mh-sent-from-msg 1))) + (widen) + (unwind-protect + (call-process-region + (point-min) (point-max) "rcvstore" nil errbuf nil folder) + (set-buffer errbuf) + (if (zerop (buffer-size)) + (message "Article saved in folder: %s" folder) + (message "%s" (buffer-string))) + (kill-buffer errbuf)))) + (setq gnus-newsgroup-last-folder folder))) (defun gnus-Folder-save-name (newsgroup headers &optional last-folder) "Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER. @@ -211,4 +106,6 @@ Otherwise, it is like +news/group." newsgroup (gnus-newsgroup-directory-form newsgroup))))) +(provide 'gnus-mh) + ;;; gnus-mh.el ends here