From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/75095 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.devel,gmane.emacs.gnus.general Subject: Re: Sending patch with Gnus Date: Thu, 16 Dec 2010 13:07:29 +0000 Message-ID: References: <871v5i212s.fsf@tux.homenetwork> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1292504879 27569 80.91.229.12 (16 Dec 2010 13:07:59 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 16 Dec 2010 13:07:59 +0000 (UTC) Cc: emacs-devel@gnu.org, ding@gnus.org, Thierry Volpiatto To: Francis Moreau Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 16 14:07:54 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PTDYk-0003Ym-Ig for ged-emacs-devel@m.gmane.org; Thu, 16 Dec 2010 14:07:53 +0100 Original-Received: from localhost ([127.0.0.1]:45751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTDYi-0002jY-RG for ged-emacs-devel@m.gmane.org; Thu, 16 Dec 2010 08:07:48 -0500 Original-Received: from [140.186.70.92] (port=60311 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTDYZ-0002j0-9w for emacs-devel@gnu.org; Thu, 16 Dec 2010 08:07:40 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PTDYV-0003up-Tm for emacs-devel@gnu.org; Thu, 16 Dec 2010 08:07:39 -0500 Original-Received: from mail-ww0-f49.google.com ([74.125.82.49]:46164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PTDYV-0003uF-MY for emacs-devel@gnu.org; Thu, 16 Dec 2010 08:07:35 -0500 Original-Received: by wwb17 with SMTP id 17so2267068wwb.30 for ; Thu, 16 Dec 2010 05:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=E12n2eKN6E/KKmSguwL9BDunxIy4xYHoNw5PEBbrMFo=; b=Xzfp2xWZsPKUYp+6674cilz/Et6sxwdD/qmwfybPKtZiXwnUKu/JBdACTe/PIcRpjR c5hflW2L9s8A62Pt8UEmTv61wH+zBaOmNVJL0hDiKZ6UDTaGtXrlBU8d56pCxtU3+RIl YsGWpYNxq8+cpZRjRCaQYjguklBZGrQrv7bW4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=XWqzqHLRx6DVyNX5frvvoEJKfrD7i04Ud4Pgvt7L8Q5q05iWCX+f+Q+YgOckG1BLOF yP6sZ18KCXttprI8gELRhkAEJc/RiM1Fm9S6xZnH+MgHVTedBTbqbEznQ/xBWZ+0zHbT FJF4ALusXKPDUJMbYPzCk2+4dnG67IlvLo5ZI= Original-Received: by 10.216.35.83 with SMTP id t61mr2356193wea.1.1292504853450; Thu, 16 Dec 2010 05:07:33 -0800 (PST) Original-Received: from Victoria.local (cpc1-cmbg13-0-0-cust596.5-4.cable.virginmedia.com [86.9.122.85]) by mx.google.com with ESMTPS id o19sm19037wee.26.2010.12.16.05.07.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 16 Dec 2010 05:07:32 -0800 (PST) In-Reply-To: (Francis Moreau's message of "Thu, 16 Dec 2010 11:01:10 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2.91 (Mac OS X 10.6.5) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:133739 gmane.emacs.gnus.general:75095 Archived-At: --=-=-= On 2010-12-16 10:01 +0000, Francis Moreau wrote: > Leo writes: > > [...] > >> >> I tweaked gnus-dired to support git-send-email (patches attached). > > Thanks for doing that. > > Unfortunately your patches don't seem to be based on Gnus repository but > rather to emacs one that I don't have. So I can't test them. OK, I put it in a separate file as attached. >> So if you have gnus-dired loaded you can in dired buffer: >> >> C-c C-m C-i import patches as DRAFTS >> C-c C-m C-s send patches directly >> >> This is handy when you need to send a large patch set. For one to two >> patches I just copy and paste. > > Funny because I feel the opposite, I use git-send-email(1) when dealing > with a large patch set since the overhead to set it up is ok in this > case. But for one patch, I do it by hands as you do, but I would prefer > to not have editing the email manually. > > But I think, your approach can still be usefull since it imports patches > as _drafts_. I don't think it's a good idea to modify the patch itself, > but modifying or adding some header fields like To, Cc, Bcc... should be > ok. And I like to check what the patch looks like before sending it. > > One other idea is to generate one or several drafts from a buffer which > contains one or several mbox files. Let's call the magic command: M-x > create-draft-from-buffer (yeah the name sucks). > > With such command, one could do in an emacs session: > > M-! git format-patch --stdout HEAD~4 > C-x o > M-x create-draft-from-buffer > > So you're putting in the *Shell Command Output* buffer the mbox files, > and then switching to that buffer and generating the drafts. The main > advantages I see is that you use a shell command to generate the buffer > containing the patches. > > BTW, if you needn't to modify the patches and only want to see them > before sending them then you can currently do this: > > M-! git format-patch --stdout HEAD~4 >/tmp/patch-set.mbox > C-x b *Group* > G f /tmp/patch-set.mbox > > This will create a nndoc group which contains all your patches as > articles. > > Then you can mark all of them and resend them with 'S D r'. But you > can't add Cc or Gcc header fields with this method. Now we have four commands (not bound to any keys for the moment) gitmail-import-mbox-as-draft gitmail-send-mbox gitmail-send-mbox-buffer gitmail-import-mbox-buffer Editing drafts in Gnus resets the date so you need this small patch (or is there a butter way to handle this?): diff --git a/lisp/gnus/gnus-draft.el b/lisp/gnus/gnus-draft.el index 1e6b7ee..d9aa2f2 100644 --- a/lisp/gnus/gnus-draft.el +++ b/lisp/gnus/gnus-draft.el @@ -102,7 +102,8 @@ (save-excursion (save-restriction (message-narrow-to-headers) - (message-remove-header "date"))) + (unless (message-fetch-field "x-draft-keep-date") + (message-remove-header "date")))) (let ((message-draft-headers (delq 'Date (copy-sequence message-draft-headers)))) (save-buffer)) Modified lisp/gnus/message.el diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 214ac0b..686f21b 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -269,7 +269,7 @@ included. Organization and User-Agent are optional." regexp)) (defcustom message-ignored-mail-headers - "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Gnus-Agent-Meta-Information:" + "^[GF]cc:\\|^Resent-Fcc:\\|^Xref:\\|^X-Draft-From:\\|^X-Draft-Keep-Date:\\|^X-Gnus-Agent-Meta-Information:" "*Regexp of headers to be removed unconditionally before mailing." :group 'message-mail :group 'message-headers -- Oracle is the new evil --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=gitmail.el Content-Transfer-Encoding: quoted-printable ;;; gitmail.el --- A similiar tool to git-send-email ;; Copyright (C) 2010 Leo ;; Author: Leo ;; Keywords: tools, convenience, mail ;; This program 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 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;;=20 ;;; Code: (eval-when-compile (require 'cl)) (require 'message) ;; (defvar message-unix-mail-delimiter) ; quiet compiler (autoload 'gnus-alive-p "gnus-util") (autoload 'dired-get-marked-files "dired") (declare-function nndraft-request-associate-buffer "nndraft") (declare-function gnus-agent-queue-setup "gnus-agent") ;; (declare-function message-fetch-field "message") ;; (declare-function message-add-header "message") ;; (declare-function message-send "message") ;; (declare-function message-narrow-to-headers-or-head "message") (defvar gitmail-read-email-map (make-sparse-keymap) "Minibuffer keymap for `gitmail-read-email'.") (set-keymap-parent gitmail-read-email-map minibuffer-local-map) (when (fboundp 'bbdb-complete-name) (define-key gitmail-read-email-map [tab] 'bbdb-complete-name)) (defsubst gitmail-read-email (prompt) (read-from-minibuffer prompt nil gitmail-read-email-map)) (defun gitmail-map-over-mbox (function) "Call FUNCTION on each mbox email in current buffer." (save-excursion (goto-char (point-min)) (let ((beg (re-search-forward message-unix-mail-delimiter nil t)) end email stop) (when beg (while (not stop) (if (re-search-forward message-unix-mail-delimiter nil 'move) (setq end (match-beginning 0)) (setq end (point)) (setq stop t)) (setq email (buffer-substring beg end)) (with-temp-buffer (insert email) (goto-char (point-min)) (re-search-forward "^$") (insert mail-header-separator) (goto-char (point-min)) (funcall function)) (setq beg (point))))))) (defun gitmail-map-over-mbox-files (function files) "Call FUNCTION on each email in mbox FILES." (dolist (f files) (with-temp-buffer (insert-file-contents f) (gitmail-map-over-mbox function)))) (defun gitmail-import-mbox-1 () (declare (special to-address cc-address)) (message-mode) (message-narrow-to-headers-or-head) (message-add-header "X-Draft-Keep-Date: Yes") (nndraft-request-associate-buffer "drafts") (unless (message-fetch-field "to") (unless to-address (setq to-address (gitmail-read-email "To: "))) (unless (string-match "[ \t]*" to-address) (message-add-header (format "To: %s" to-address)))) (unless (or (message-fetch-field "cc") (eq cc-address 'no)) (unless cc-address (setq cc-address (if (yes-or-no-p "Add Cc addresses? ") (gitmail-read-email "Cc: ") 'no))) (unless (eq cc-address 'no) (message-add-header (format "Cc: %s" cc-address)))) (save-buffer 0)) (defun gitmail-send-mbox-1 () (declare (special to-address cc-address)) (message-mode) (message-narrow-to-headers-or-head) (unless (message-fetch-field "to") (unless to-address (setq to-address (gitmail-read-email "To address: "))) (message-add-header (format "To: %s" to-address))) (unless (or (message-fetch-field "cc") (eq cc-address 'no)) (unless cc-address (setq cc-address (if (yes-or-no-p "Add Cc addresses? ") (gitmail-read-email "Cc: ") 'no))) (unless (eq cc-address 'no) (message-add-header (format "Cc: %s" cc-address)))) (message-send)) ;;;###autoload (defun gitmail-import-mbox-as-draft (&rest mbox-files) "Import emails in MBOX-FILES into the draft group." (interactive (if (derived-mode-p 'dired) (dired-get-marked-files) (file-expand-wildcards (read-file-name "Find mbox file: ")= t))) (assert (gnus-alive-p) nil "Gnus is not running") (gnus-agent-queue-setup "drafts") (let (to-address cc-address) (gitmail-map-over-mbox-files 'gitmail-import-mbox-1 mbox-files))) ;;;###autoload (defun gitmail-send-mbox (&rest mbox-files) "Send all emails in MBOX-FILES." (interactive (if (derived-mode-p 'dired) (dired-get-marked-files) (file-expand-wildcards (read-file-name "Find mbox file: ")= t))) (let (to-address cc-address) (gitmail-map-over-mbox-files 'gitmail-send-mbox-1 mbox-files))) ;;;###autoload (defun gitmail-send-mbox-buffer (&optional buffer) "Send mbox emails in BUFFER (default current buffer)." (interactive) (let (to-address cc-address) (with-current-buffer (or buffer (current-buffer)) (gitmail-map-over-mbox 'gitmail-send-mbox-1)))) ;;;###autoload (defun gitmail-import-mbox-buffer (&optional buffer) "Send mbox emails in BUFFER (default current buffer)." (interactive) (assert (gnus-alive-p) nil "Gnus is not running") (let (to-address cc-address) (with-current-buffer (or buffer (current-buffer)) (gitmail-map-over-mbox 'gitmail-import-mbox-1)))) (provide 'gitmail) ;;; gitmail.el ends here --=-=-=--