New patcher comin'in hot
Mike Kupfer
mike.kupfer at xemacs.org
Thu Jun 10 18:43:13 EDT 2010
Didier Verna wrote:
> Mike Kupfer <mike.kupfer at xemacs.org> wrote:
>
> > Hi Didier, are you open to feature patches at this point? I have
> > patches for patcher 3.x to support MH-E, and I'd be happy to update
> > them for 4.0 and send you the results.
>
> No problem. Shoot!
Okay, here's what I have so far. It's very close to my patch for
patcher 3.11, which seemed to work okay, but it errors out in
patcher-after-send with patcher 4.0 (backtrace below).
I'm not entirely sure I'm on the right path. MH-E has its own major
mode for sending email, and it doesn't support a post-send hook. So I
wrote a helper function to send the message and then invoke
patcher-after-send. Maybe I should forget about trying to invoke
patcher-after-send?
Here's the backtrace:
Debugger entered--Lisp error: (error "patcher-project-sources accessing a non-patcher-project")
signal(error ("patcher-project-sources accessing a non-patcher-project"))
cerror("patcher-project-sources accessing a non-patcher-project" nil)
apply(cerror "patcher-project-sources accessing a non-patcher-project" nil)
error("patcher-project-sources accessing a non-patcher-project" nil)
(or (and (vectorp cl-x) (>= ... 15) (memq ... cl-struct-patcher-project-tags)) (error "patcher-project-sources accessing a non-patcher-project" cl-x))
(progn (or (and ... ... ...) (error "patcher-project-sources accessing a non-patcher-project" cl-x)) (aref cl-x 14))
(block patcher-project-sources (or (and ... ... ...) (error "patcher-project-sources accessing a non-patcher-project" cl-x)) (aref cl-x 14))
patcher-project-sources(nil)
(list nil (patcher-project-sources project))
(or (memq :sources --rest--34941) (list nil (patcher-project-sources project)))
(cdr (or (memq :sources --rest--34941) (list nil ...)))
(car (cdr (or ... ...)))
(let* ((sources ...) (override-kill ...) (kill ...)) (let (...) (while --keys--34942 ...)) (block patcher-unlink-sources (dolist ... ...)))
patcher-unlink-sources(nil)
(with-fboundp-1 (quote patcher-unlink-sources) (patcher-unlink-sources project))
(with-fboundp (quote patcher-unlink-sources) (patcher-unlink-sources project))
(declare-fboundp (patcher-unlink-sources project))
patcher-delete-project(nil)
patcher-after-send()
(lambda nil "Helper function for patcher-mail-mh. Sends the composed mail and\n then invokes the patcher post-send cleanup function." (interactive) (mh-send-letter) (patcher-after-send))()
call-interactively(patcher-send-mh)
(dispatch-event "[internal]")
And here's the code:
lisp/ChangeLog addition:
2010-06-10 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-mail.el (patcher-send-mh): New. Helper function to
send finished mail and invoke patcher-after-send.
* 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,40 @@ 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. So
+ ;; bind the send key sequence to a custom function that includes the
+ ;; patcher post-send cleanup function.
+ (local-set-key "\C-c\C-c" 'patcher-send-mh))
+
+(defun patcher-send-mh ()
+ "Helper function for patcher-mail-mh. Sends the composed mail and
+ then invokes the patcher post-send cleanup function."
+ (interactive)
+ (mh-send-letter)
+ (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")))
Thanks in advance for any guidance you can give me here.
mike
More information about the XEmacs-Beta
mailing list