-;;; 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,95,96 Free Software Foundation, Inc.
;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
-;; Lars Ingebrigtsen <larsi@ifi.uio.no>
+;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
;; Keywords: news
;; This file is part of GNU Emacs.
(require 'mh-e)
(require 'mh-comp)
(require 'gnus)
+(require 'gnus-msg)
+(eval-when-compile (require 'cl))
+
+(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")
+ (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).
;; 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*")))
+ (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 (get-buffer-create " *Gnus rcvstore*"))
+ ;; Find the rcvstore program.
+ (exec-path (if mh-lib (cons mh-lib exec-path) exec-path)))
(gnus-eval-in-buffer-window
- gnus-article-buffer
+ gnus-original-article-buffer
(save-restriction
(widen)
(unwind-protect
- (call-process-region (point-min) (point-max)
- (expand-file-name "rcvstore" mh-lib)
- nil errbuf nil folder)
+ (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)
(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."
- ;; First of all, prepare mhe mail buffer.
- ;; Bug fix by Timo METZEMAKERS <metzemakers@labri.u-bordeaux.fr>.
- (pop-to-buffer gnus-article-buffer)
- (let (from cc subject date to reply-to (buffer (current-buffer)))
- (save-restriction
- (gnus-article-show-all-headers) ;I don't think this is really needed.
- (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")
- date (gnus-fetch-field "date"))
- (setq mh-show-buffer buffer)
- (setq to (or reply-to from))
- (mh-find-path)
- (mh-send to (or cc "") subject)
- (save-excursion
- (mh-insert-fields
- "In-reply-to:"
- (concat
- (substring from 0 (string-match " *at \\| *@ \\| *(\\| *<" from))
- "'s message of " date)))
- (setq mh-sent-from-folder buffer)
- (setq mh-sent-from-msg 1)
- ))
- ;; 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
-;; <itojun@ingram.mt.cs.keio.ac.jp>
-
-(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 beg)
- ;;(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 to (or cc "") subject)
- (save-excursion
- (goto-char (point-max))
- (setq beg (point))
- (insert "\n------- Forwarded Message\n\n")
- (insert-buffer buffer)
- (goto-char (point-max))
- (insert "\n------- End of Forwarded Message\n")
- (goto-char beg)
- (while (setq beg (next-single-property-change (point) 'invisible))
- (goto-char beg)
- (delete-region beg (or (next-single-property-change
- (point) 'invisible)
- (point-max))))
- (setq mh-sent-from-folder buffer)
- (setq mh-sent-from-msg 1))))
-
-(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))
+(defun gnus-mh-mail-setup (to subject in-reply-to cc replybuffer actions)
+ (let ((config (current-window-configuration)))
(mh-find-path)
- (mh-send-other-window to cc subject)
- (setq mh-sent-from-folder (current-buffer))
- (setq mh-sent-from-msg 1)))
+ (mh-send-sub (or to "") (or cc "") (or subject "") config)
+ (when in-reply-to
+ (save-excursion
+ (goto-char (point-min))
+ (insert "In-Reply-To: " in-reply-to "\n")))
+ (setq mh-sent-from-folder gnus-article-copy)
+ (setq mh-sent-from-msg 1)
+ (setq gnus-mail-buffer (buffer-name (current-buffer)))
+ (use-local-map (copy-keymap (current-local-map)))
+ (local-set-key "\C-c\C-c" 'gnus-mh-mail-send-and-exit)
+ (setq mh-show-buffer gnus-article-copy)
+ (setq mh-previous-window-config config)))
+
+(defun gnus-mh-mail-send-and-exit (&optional dont-send)
+ "Send the current mail and return to Gnus."
+ (interactive)
+ (let* ((reply gnus-article-reply)
+ (winconf gnus-prev-winconf)
+ (address-group gnus-add-to-address)
+ (to-address (and address-group
+ (mail-fetch-field "to"))))
+ (setq gnus-add-to-address nil)
+ (or dont-send (mh-send-letter))
+ (bury-buffer)
+ ;; This mail group doesn't have a `to-address', so we add one
+ ;; here. Magic!
+ (and to-address
+ (gnus-group-add-parameter
+ address-group (cons 'to-address to-address)))
+ (if (get-buffer gnus-group-buffer)
+ (progn
+ (if (gnus-buffer-exists-p (car-safe reply))
+ (progn
+ (set-buffer (car reply))
+ (and (cdr reply)
+ (gnus-summary-mark-article-as-replied
+ (cdr reply)))))
+ (and winconf (set-window-configuration winconf))))))
(defun gnus-Folder-save-name (newsgroup headers &optional last-folder)
"Generate folder name from NEWSGROUP, HEADERS, and optional LAST-FOLDER.