From: treese@lcs.mit.edu (Win Treese)
Subject: Re: gnus-mail-forward-using-mhe?
Organization: MIT Laboratory for Computer Science
Distribution: gnu
Date: Thu, 15 Oct 1992 02:58:41 GMT


I'd like to thank

	Uri <uunet!robcad!uri>
	David S. Goldberg <dsg@blackbird.mitre.org>
	Stephen S. Hultquist <ssh@vnet.ibm.com>
	Stanley Lanning <lanning@pure.com>
	Nick Dokos <nick@osf.org>
	Paul Palmer <palmerp@math.orst.edu>

for sending suggestions and code for gnus-mail-forward-using-mhe.

For those who like different code, I've included the responses below;
they're all fairly short.  Two of the responses (Uri's and Stephen
Hultquist's) were essentially the same.  If anyone is looking to just
pick one out without going through the different implementations, the
one in the first message (Uri's) seems to get the job done just fine.
Your mileage and opinion may vary.

Win Treese
MIT Laboratory for Computer Science                  DEC Cambridge Research Lab
treese@lcs.mit.edu					     treese@crl.dec.com

	Calvin's Prayer:

	"The strength to change what I can,
	 The inability to accept what I can't,
	 And the incapacity to tell the difference."


------- Forwarded Messages

To: Win Treese <uunet!lcs.mit.edu!treese@uunet.uu.net>
Cc: info-gnus-english@archive.cis.ohio-state.edu
Subject: Re: gnus-mail-forward-using-mhe? 
Date: Mon, 05 Oct 92 08:41:16 +0200
From: uunet!robcad!uri@uunet.uu.net

Hi,

It *is* missing, indeed. So, following is what I have.

Uri.

;; gnus-mh|uunet!robcad!urirobcad
;; |Forwarding message via mh (missing in gnuspost.el)
;; |1992-01-01|1.0|

;; This package contains a replacement for the missing 
;; gnus-mail-forward-using-mhe for GNUS 3.14

(require 'gnus)

(defun gnus-mail-forward-using-mhe ()
  "Forward the current message to other users using mh-e."
  ;; First of all, prepare mhe mail buffer.
  (let ((to (read-string "To: "))
	(cc (read-string "Cc: "))
	(forward-buffer (current-buffer)))
    (gnus-Article-show-all-headers)	;I don't think this is really needed.
    (setq subject (concat "[" (gnus-fetch-field "from") ": "
			  (gnus-fetch-field "subject") "]"))
    (setq mh-show-buffer forward-buffer)
    (mh-find-path)
    (mh-send to cc subject)
    (setq mh-sent-from-folder forward-buffer)
    (setq mh-sent-from-msg 1)
    ;; Second, yank the forwarded message
    (save-excursion
      (insert "\n------- Forwarded Message\n\n")
      (insert-buffer forward-buffer)
      (goto-char (point-max))
      (insert "\n------- End of Forwarded Message\n\n")
      ;; You have a chance to arrange the message.
      (run-hooks 'gnus-mail-forward-hook))))

------- Message 2

From: "David S. Goldberg" <dsg@blackbird.mitre.org>
Message-Id: <9210051300.AA25884@blackbird.mitre.org>
To: Win Treese <treese@lcs.mit.edu>
Subject: Re: gnus-mail-forward-using-mhe?
Date: Mon, 05 Oct 92 09:00:16 D


It seems to be missing from gnusmail.el.  I found the following posted
(here I think) a couple months ago.  I modified it slightly - the
original's message delimiters weren't quite the same.

Dave Goldberg                      UNIX Systems Programmer/Administrator
Post: The Mitre Corporation MS B020 202 Burlington Rd. Bedford, MA 01730
Phone: 617-271-2460
Domain: dsg@mbunix.mitre.org  UUCP: {your neighborhood}!linus!mbunix!dsg 

; forward a news article using mh (from khera@cs.duke.edu (Vivek
; Khera), renamed and modifed slightly by dsg)
(defun gnus-mail-forward-using-mhe ()
  "Forward the current message to another user.
Mostly from rmail.el and gnusmail.el."
  (interactive)
  (if (not (get-buffer gnus-Article-buffer))
      (call-interactively 'gnus-Subject-next-page))
  (switch-to-buffer gnus-Article-buffer)
  (let ((forward-buffer gnus-Article-buffer) ; used to be (current-buffer)
        (subject (concat "["
                         (mail-strip-quoted-names (gnus-fetch-field "From"))
                         ": " (or (gnus-fetch-field "Subject") "") "]")))
    (mh-find-path)
    (mh-send "" "" subject)
    (goto-char (point-min))
    (save-excursion
      (goto-char (point-max))
      (forward-line 1)
      (insert "\n------- Forwarded Message\n\n")
      (insert-buffer forward-buffer)
      (goto-char (point-max))
      (insert "\n\n------- End of Forwarded Message\n"))))

------- Message 3

Message-Id: <9210051352.AA12617@snow.boulder.ibm.com>
To: Win Treese <treese@lcs.mit.edu>
Subject: Re: gnus-mail-forward-using-mhe?
Date: Mon, 05 Oct 92 07:52:34 -0700
From: "Stephen S. Hultquist" <ssh@vnet.ibm.com>

Here's the one I use...

ssh

- -- cut here --

; forward a news article using mh
; (defun gnus-Subject-forward-mh ()
(defun gnus-mail-forward-using-mhe ()
  "Forward the current message to other users using mh-e."
  ;; First of all, prepare mhe mail buffer.
  (let ((to (read-string "To: "))
        (cc (read-string "Cc: "))
        (forward-buffer (current-buffer)))
    (gnus-Article-show-all-headers)     ;I don't think this is really needed.
    (setq subject (concat "[" (gnus-fetch-field "from") ": "
                          (gnus-fetch-field "subject") "]"))
    (setq mh-show-buffer forward-buffer)
    (mh-find-path)
    (mh-send to cc subject)
    (setq mh-sent-from-folder forward-buffer)
    (setq mh-sent-from-msg 1)
    ;; Second, yank the forwarded message
    (save-excursion
      (insert "\n------- Forwarded Message\n\n")
      (insert-buffer forward-buffer)
      (goto-char (point-max))
      (insert "\n------- End of Forwarded Message\n\n")
      ;; You have a chance to arrange the message.
      (run-hooks 'gnus-mail-forward-hook))))

------- Message 4

Message-Id: <199210051659.AA07671@pure.pure.com>
To: Win Treese <treese@lcs.mit.edu>
Subject: Re: gnus-mail-forward-using-mhe?
Date: Mon, 05 Oct 92 09:58:05 -0700
From: Stanley Lanning <lanning@pure.com>

Here ya go:

;; There is no gnus-forward-using-mhe in the gnus package,
;; so here's one...
(defun gnus-mail-forward-using-mhe ()
  (require 'mh-e)
  (mh-find-path)			;initialize MH paths
  (let ((forward-buffer (current-buffer))
	(config (current-window-configuration))
	(pop-up-windows t)		;???
	(to (read-string "To: "))
	(cc (read-string "Cc: "))
	(subject
	 (concat "[" gnus-newsgroup-name "] "
		 ;;(mail-strip-quoted-names (gnus-fetch-field "From")) ": "
		 (or (gnus-fetch-field "Subject") "")))
	(folder mh-current-folder)
	(msg-num (mh-get-msg-num nil)))
    (let ((draft (mh-read-draft
		  "message"
		  (if (file-exists-p
		       (expand-file-name "components" mh-user-path))
		      (expand-file-name "components" mh-user-path)
		    (if (file-exists-p
			 (expand-file-name "components" mh-lib))
			(expand-file-name "components" mh-lib)
		      (error "Can't find components file")))
		  nil)))
      (mh-insert-fields "To:" to "Subject:" subject "Cc:" cc)
      (set-buffer-modified-p nil)
      (goto-char (point-max))
      (save-excursion
	(goto-char (point-max))
	(insert "\n------- Start of forwarded message -------\n")
	(insert-buffer forward-buffer)
	(goto-char (point-max))
	(insert "------- End of forwarded message -------\n")
	;; You have a chance to arrange the message.
	(run-hooks 'gnus-mail-forward-hook)
	)
      (message "Composing a message...done")
      (mh-compose-and-send-mail draft "" folder msg-num
				to subject cc
				nil nil config))))


- -----------------

Family is something which goes back to the nucleus of civilization.
 And the very beginnings of civilization, the very beginnings of this
 country, goes back to the family.
                -- Vice President Dan Quayle.

------- Message 5

Message-Id: <9210061558.AA12966@osf.osf.org>
To: Win Treese <treese@lcs.mit.edu>
Reply-To: nick@osf.org
Subject: Re: gnus-mail-forward-using-mhe?
Date: Tue, 06 Oct 92 11:57:08 +0000
From: nick@osf.org

It's missing. But before you implement it, consider Jaime Zawinski's
gnus-mark.el package. Here is the LCD info:

gnus-mark	  91-06-28
     Jamie Zawinski, <jwz@lucid.com>
     archive.cis.ohio-state.edu:/pub/gnu/emacs/elisp-archive/misc/gnus-mark.el.Z
     Operate on more than one news article at a time

You can mark a bunch of articles and then forward them all at once. It still uses
mail to mail them but the change to use mh is trivial - and I have that if you
are interested.

Nick Dokos	nick@osf.org	
OSF Systems Engineering

Member of the League for Programming Freedom - write to league@prep.ai.mit.edu

------- Message 6

Message-Id: <9210072243.AA23840@argus.MATH.ORST.EDU>
To: Win Treese <treese@lcs.mit.edu>
From: Paul Palmer <palmerp@math.orst.edu>
Really-From: palmerp@math.orst.edu
Subject: Re: gnus-mail-forward-using-mhe?
Date: Wed, 07 Oct 92 15:43:46 PDT

>> Newsgroups: gnu.emacs.gnus
>> Message-ID: <TREESE.92Oct4200144@vanilla.lcs.mit.edu>
>> Date: 5 Oct 92 01:01:44 GMT

>> In gnus 3.14, gnusmail.el refers to gnus-mail-forward-using-mhe, but it
>> seems to be missing the procedure.  Before I hack one up, has someone
>> else implemented it?  (Or do I just have a mangled copy of gnusmail.el?)
>> 
>> Thanks very much.

>> treese@lcs.mit.edu	     treese@crl.dec.com

No, it's missing from the distribution. I have several versions from people on
the net, none of which work for me. If you like, I can send them for you to
hack from. Here's what I do:

(setq gnus-mail-reply-method 'gnus-mail-reply-using-mhe)
(setq gnus-mail-other-window-method 'gnus-mail-other-window-using-mhe)
(fset 'forward-article "R<In-Reply-To<")
(setq gnus-Startup-hook
      (function
       (lambda ()
	 (define-key gnus-Subject-mode-map "\C-f" 'forward-article))))

It works, but isn't great.

Paul Palmer
Department of Mathematics     	E-mail: palmerp@math.orst.edu
Kidder Hall 368
Oregon State University, Corvallis, Oregon 97331-4605

------- End of Forwarded Messages