[PATCH] MH-E support for Patcher 4.0

Mike Kupfer mike.kupfer at xemacs.org
Mon Jun 14 15:02:53 EDT 2010


Didier Verna wrote:

>   Here, I think that after calling mh-send-letter, you might not be in
> the mail buffer anymore, so the value of the (local) variable
> patcher-project is nil. 

Yes, you're right; thanks.  Looking at mh-send-letter, I see that it
normally destroys the mail buffer after sending it.  So I suspect that
using with-current-buffer is likely to misbehave.  But I can hang the
cleanup call off of the buffer's kill-buffer-hook.  That seems to work.

How does this look?

mike

lisp/ChangeLog addition:

2010-06-14  Mike Kupfer  <mike.kupfer at xemacs.org>

	Add support to patcher for MH-E.
	* patcher-mail.el (patcher-mail-mh): New.  Plugin function for
	'mh type (MH-E).
	* patcher-project.el (mail-method): Add 'mh choice.


patcher source patch:
Diff command:   hg diff --git --show-function 
Files affected: lisp/patcher-mail.el lisp/patcher-project.el

diff --git a/lisp/patcher-mail.el b/lisp/patcher-mail.el
--- a/lisp/patcher-mail.el
+++ b/lisp/patcher-mail.el
@@ -842,6 +842,33 @@ buffer).  Otherwise, the group is prompt
     (message-goto-body)
     (patcher-install-send-hooks)))
 
+(defun patcher-mail-mh (project subject)
+  "Prepare a patch-related mail using MH-E.
+This function uses the `:to-address' project option to determine the email
+address for sending the message.  Otherwise, the address is prompted
+for."
+  ;; We can't guarantee that there is an MH-E folder buffer
+  ;; available.  So use mh-smail to create the message, then fill it
+  ;; in.
+  (patcher-with-mail-parameters project
+    (let ((to (or (patcher-project-option project :to-address)
+		  (read-string "To address: "))))
+      (mh-smail)
+      (goto-char (point-min))
+      (re-search-forward "^To:")
+      (kill-entire-line)
+      (insert "To: " to "\n")
+      (goto-char (point-min))
+      (re-search-forward "^Subject:")
+      (kill-entire-line)
+      (insert "Subject: " subject "\n")))
+  (goto-char (point-max))
+  (add-local-hook 'mh-before-send-letter-hook 'patcher-before-send)
+  ;; MH-E doesn't have a hook for after the message has been sent.
+  ;; But it usually kills the draft buffer, so use kill-buffer-hook
+  ;; instead.
+  (add-local-hook 'kill-buffer-hook 'patcher-after-send))
+
 (defun* patcher-mail-fake
     (project subject &aux (buffer (generate-new-buffer "*Patcher Fake Mail*")))
   "Prepare a patch-related fake mail.
diff --git a/lisp/patcher-project.el b/lisp/patcher-project.el
--- a/lisp/patcher-project.el
+++ b/lisp/patcher-project.el
@@ -117,7 +117,7 @@ the real project's name."
   "*Default method used by Patcher to prepare a mail.
 
 Currently, there are four built-in methods: 'compose-mail \(the default),
-'sendmail, 'message, 'gnus and 'fake.  Please refer to the corresponding
+'sendmail, 'message, 'gnus, 'mh and 'fake.  Please refer to the corresponding
 `patcher-mail-*' function for a description of each method.
 
 You can also define your own method, say `foo'.  In that case, you *must*
@@ -130,6 +130,7 @@ see how it's done for the built-in metho
 	   (const sendmail)
 	   (const message)
 	   (const gnus)
+	   (const mh)
 	   (const fake)
 	   (symbol :tag "other")))
 



More information about the XEmacs-Beta mailing list