all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: Sending patch with Gnus
       [not found] <m2aak7m36y.fsf@gmail.com>
@ 2010-12-15 19:21 ` Lars Magne Ingebrigtsen
  2010-12-15 21:11   ` Thierry Volpiatto
  2010-12-15 21:27   ` Tassilo Horn
  0 siblings, 2 replies; 20+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-12-15 19:21 UTC (permalink / raw)
  To: emacs-devel; +Cc: ding

Francis Moreau <francis.moro@gmail.com> writes:

> Since Gnus is using Git as SCM, I'm wondering if some of you have a
> magical function that can be used to send patch easily.
>
> For example, git-format-patch(1) generates a patch with all header
> fields set up such as "Subject, From..." and I'd like to create a new
> mail automatically from the generated patch using the header fields in
> the patch.
>
> Currently I'm starting a new mail and in the message body I'm inserting
> the output from git-format-patch(1) and then I do some clean up
> _manually_.
>
> Using git-send-email(1) with its ton of options is too complex for me
> when I need to send only 1 patch.

This sounds like a good idea, but I think that it might belong more to
vc-mode than to Gnus, so I've Cc'd it to emacs-devel.

Does the VC system have a general "make-an-email-from-this-patch"
mechanism? 

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-15 19:21 ` Sending patch with Gnus Lars Magne Ingebrigtsen
@ 2010-12-15 21:11   ` Thierry Volpiatto
  2010-12-15 21:50     ` Francis Moreau
  2010-12-16  6:09     ` Leo
  2010-12-15 21:27   ` Tassilo Horn
  1 sibling, 2 replies; 20+ messages in thread
From: Thierry Volpiatto @ 2010-12-15 21:11 UTC (permalink / raw)
  To: emacs-devel; +Cc: ding

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Francis Moreau <francis.moro@gmail.com> writes:
>
>> Since Gnus is using Git as SCM, I'm wondering if some of you have a
>> magical function that can be used to send patch easily.
>>
>> For example, git-format-patch(1) generates a patch with all header
>> fields set up such as "Subject, From..." and I'd like to create a new
>> mail automatically from the generated patch using the header fields in
>> the patch.
>>
>> Currently I'm starting a new mail and in the message body I'm inserting
>> the output from git-format-patch(1) and then I do some clean up
>> _manually_.
>>
>> Using git-send-email(1) with its ton of options is too complex for me
>> when I need to send only 1 patch.
>
> This sounds like a good idea, but I think that it might belong more to
> vc-mode than to Gnus, so I've Cc'd it to emacs-devel.
>
> Does the VC system have a general "make-an-email-from-this-patch"
> mechanism? 
DVC have this.
M-x dvc-export-via-mail

-- 
A+ Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-15 19:21 ` Sending patch with Gnus Lars Magne Ingebrigtsen
  2010-12-15 21:11   ` Thierry Volpiatto
@ 2010-12-15 21:27   ` Tassilo Horn
  2010-12-15 21:41     ` Francis Moreau
  1 sibling, 1 reply; 20+ messages in thread
From: Tassilo Horn @ 2010-12-15 21:27 UTC (permalink / raw)
  To: ding; +Cc: Lars Magne Ingebrigtsen, emacs-devel

On Wednesday 15 December 2010 20:21:31 Lars Magne Ingebrigtsen wrote:

> > Currently I'm starting a new mail and in the message body I'm
> > inserting the output from git-format-patch(1) and then I do some
> > clean up _manually_.
> >
> > Using git-send-email(1) with its ton of options is too complex for
> > me when I need to send only 1 patch.
> 
> This sounds like a good idea, but I think that it might belong more to
> vc-mode than to Gnus, so I've Cc'd it to emacs-devel.

I do the same as Francis, e.g., insert and edit.  And at least with git,
you should write your accompanying prose text below the signature.
That's a bit awkward, but it allows to pipe the complete email to "git
am" (is it am?) without having to extract the patch manually first.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-15 21:27   ` Tassilo Horn
@ 2010-12-15 21:41     ` Francis Moreau
  2010-12-15 22:06       ` Tassilo Horn
  0 siblings, 1 reply; 20+ messages in thread
From: Francis Moreau @ 2010-12-15 21:41 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: ding, Lars Magne Ingebrigtsen, emacs-devel

Tassilo Horn <tassilo@member.fsf.org> writes:

> On Wednesday 15 December 2010 20:21:31 Lars Magne Ingebrigtsen wrote:
>
>> > Currently I'm starting a new mail and in the message body I'm
>> > inserting the output from git-format-patch(1) and then I do some
>> > clean up _manually_.
>> >
>> > Using git-send-email(1) with its ton of options is too complex for
>> > me when I need to send only 1 patch.
>> 
>> This sounds like a good idea, but I think that it might belong more to
>> vc-mode than to Gnus, so I've Cc'd it to emacs-devel.
>
> I do the same as Francis, e.g., insert and edit.  And at least with git,
> you should write your accompanying prose text below the signature.
> That's a bit awkward, but it allows to pipe the complete email to "git
> am" (is it am?) without having to extract the patch manually first.

I'm not sure to understand this.

What do you mean by "accompanying prose text" ?

-- 
Francis



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-15 21:11   ` Thierry Volpiatto
@ 2010-12-15 21:50     ` Francis Moreau
  2010-12-15 21:54       ` Lars Magne Ingebrigtsen
  2010-12-16  6:09     ` Leo
  1 sibling, 1 reply; 20+ messages in thread
From: Francis Moreau @ 2010-12-15 21:50 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: emacs-devel, ding

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
>> Francis Moreau <francis.moro@gmail.com> writes:
>>
>>> Since Gnus is using Git as SCM, I'm wondering if some of you have a
>>> magical function that can be used to send patch easily.
>>>
>>> For example, git-format-patch(1) generates a patch with all header
>>> fields set up such as "Subject, From..." and I'd like to create a new
>>> mail automatically from the generated patch using the header fields in
>>> the patch.
>>>
>>> Currently I'm starting a new mail and in the message body I'm inserting
>>> the output from git-format-patch(1) and then I do some clean up
>>> _manually_.
>>>
>>> Using git-send-email(1) with its ton of options is too complex for me
>>> when I need to send only 1 patch.
>>
>> This sounds like a good idea, but I think that it might belong more to
>> vc-mode than to Gnus, so I've Cc'd it to emacs-devel.
>>
>> Does the VC system have a general "make-an-email-from-this-patch"
>> mechanism? 
> DVC have this.
> M-x dvc-export-via-mail

Well, I don't use VC (or DVC) mode because I just prefer using the SCM
directly since it allows to do much more things. And IIRC, VC mode do
some automatic things which can slow down a lot emacs when dealing with
large repos.

-- 
Francis



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-15 21:50     ` Francis Moreau
@ 2010-12-15 21:54       ` Lars Magne Ingebrigtsen
  0 siblings, 0 replies; 20+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-12-15 21:54 UTC (permalink / raw)
  To: ding; +Cc: emacs-devel

Francis Moreau <francis.moro@gmail.com> writes:

> Well, I don't use VC (or DVC) mode because I just prefer using the SCM
> directly since it allows to do much more things. And IIRC, VC mode do
> some automatic things which can slow down a lot emacs when dealing with
> large repos.

I use three different SCMs daily, and I'd go (even more) insane if
vc-mode didn't wallpaper over all most of the differences between them.

And I haven't really seen any major `M-x vc-dir' slowdowns (except when
the underlying SCM is slow).

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-15 21:41     ` Francis Moreau
@ 2010-12-15 22:06       ` Tassilo Horn
  2010-12-15 22:27         ` Francis Moreau
  0 siblings, 1 reply; 20+ messages in thread
From: Tassilo Horn @ 2010-12-15 22:06 UTC (permalink / raw)
  To: Francis Moreau; +Cc: Lars Magne Ingebrigtsen, ding, emacs-devel

Francis Moreau <francis.moro@gmail.com> writes:

Hi Francis,

>> I do the same as Francis, e.g., insert and edit.  And at least with
>> git, you should write your accompanying prose text below the
>> signature.  That's a bit awkward, but it allows to pipe the complete
>> email to "git am" (is it am?) without having to extract the patch
>> manually first.
>
> I'm not sure to understand this.
>
> What do you mean by "accompanying prose text" ?

The text in which you explain for what it's good for, where you ask the
list to review it, in contrast to the 1-line summary git puts in the
subject and the following full commit message, which starts the mail.

Bye,
Tassilo



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-15 22:06       ` Tassilo Horn
@ 2010-12-15 22:27         ` Francis Moreau
  0 siblings, 0 replies; 20+ messages in thread
From: Francis Moreau @ 2010-12-15 22:27 UTC (permalink / raw)
  To: Tassilo Horn; +Cc: Lars Magne Ingebrigtsen, ding, emacs-devel

Hello Tassilo,

Tassilo Horn <tassilo@member.fsf.org> writes:

> Francis Moreau <francis.moro@gmail.com> writes:
>
> Hi Francis,
>
>>> I do the same as Francis, e.g., insert and edit.  And at least with
>>> git, you should write your accompanying prose text below the
>>> signature.  That's a bit awkward, but it allows to pipe the complete
>>> email to "git am" (is it am?) without having to extract the patch
>>> manually first.
>>
>> I'm not sure to understand this.
>>
>> What do you mean by "accompanying prose text" ?
>
> The text in which you explain for what it's good for, where you ask the
> list to review it, in contrast to the 1-line summary git puts in the
> subject and the following full commit message, which starts the mail.

Ah I see, then I think you should place such text like this:


  [PATCH] A cool patch to speed up Gnus ;)
  
  A full commit message
  
  ---
  
  The text placed here is usually a message that is addressed to the list
  but won't be part of the commit.
  
   texi/ChangeLog |    4 ++++
   texi/gnus.texi |    2 +-
   2 files changed, 5 insertions(+), 1 deletions(-)
  
  diff --git a/texi/ChangeLog b/texi/ChangeLog
  index 8c0fec4..bf494ee 100644
  --- a/texi/ChangeLog
  +++ b/texi/ChangeLog

  [...]
  
  -- 
  1.7.3.2

-- 
Francis



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-15 21:11   ` Thierry Volpiatto
  2010-12-15 21:50     ` Francis Moreau
@ 2010-12-16  6:09     ` Leo
  2010-12-16 10:01       ` Francis Moreau
  2010-12-16 15:53       ` Lars Magne Ingebrigtsen
  1 sibling, 2 replies; 20+ messages in thread
From: Leo @ 2010-12-16  6:09 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: ding, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1529 bytes --]

On 2010-12-15 21:11 +0000, Thierry Volpiatto wrote:
> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
>> Francis Moreau <francis.moro@gmail.com> writes:
>>
>>> Since Gnus is using Git as SCM, I'm wondering if some of you have a
>>> magical function that can be used to send patch easily.
>>>
>>> For example, git-format-patch(1) generates a patch with all header
>>> fields set up such as "Subject, From..." and I'd like to create a new
>>> mail automatically from the generated patch using the header fields in
>>> the patch.
>>>
>>> Currently I'm starting a new mail and in the message body I'm inserting
>>> the output from git-format-patch(1) and then I do some clean up
>>> _manually_.
>>>
>>> Using git-send-email(1) with its ton of options is too complex for me
>>> when I need to send only 1 patch.
>>
>> This sounds like a good idea, but I think that it might belong more to
>> vc-mode than to Gnus, so I've Cc'd it to emacs-devel.
>>
>> Does the VC system have a general "make-an-email-from-this-patch"
>> mechanism? 
> DVC have this.
> M-x dvc-export-via-mail

I tweaked gnus-dired to support git-send-email (patches 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.

Note if you want your patches to have nice threading, check out the
option --thread for git-format-patch.

Cheers,
Leo

-- 
Oracle is the new evil


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-New-functions-to-send-emails-in-mbox-files-from-dire.patch --]
[-- Type: text/x-diff, Size: 3854 bytes --]

From c6222dcbb210dae3998fed3400d4c7de08c1bb82 Mon Sep 17 00:00:00 2001
From: Leo <sdl.web@gmail.com>
Date: Tue, 20 Jul 2010 23:35:13 +0100
Subject: [PATCH 1/3] New functions to send emails in mbox files from dired

New functions gnus-dired-map-over-mbox,
gnus-dired-import-mbox-as-draft and gnus-dired-send-mbox.

Load message.el in gnus-dired-map-over-mbox for
message-unix-mail-delimiter.
---
 lisp/gnus/gnus-dired.el |   63 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 62 insertions(+), 1 deletions(-)

diff --git a/lisp/gnus/gnus-dired.el b/lisp/gnus/gnus-dired.el
index 595a9fe..9d8713c 100644
--- a/lisp/gnus/gnus-dired.el
+++ b/lisp/gnus/gnus-dired.el
@@ -40,6 +40,7 @@
 ;;; Code:
 
 (require 'dired)
+(eval-when-compile (require 'cl))
 (autoload 'mml-attach-file "mml")
 (autoload 'mm-default-file-encoding "mm-decode");; Shift this to `mailcap.el'?
 (autoload 'mailcap-extension-to-mime "mailcap")
@@ -64,8 +65,10 @@
   (setq gnus-dired-mode-map (make-sparse-keymap))
 
   (define-key gnus-dired-mode-map "\C-c\C-m\C-a" 'gnus-dired-attach)
+  (define-key gnus-dired-mode-map "\C-c\C-m\C-i" 'gnus-dired-import-mbox-as-draft)
   (define-key gnus-dired-mode-map "\C-c\C-m\C-l" 'gnus-dired-find-file-mailcap)
-  (define-key gnus-dired-mode-map "\C-c\C-m\C-p" 'gnus-dired-print))
+  (define-key gnus-dired-mode-map "\C-c\C-m\C-p" 'gnus-dired-print)
+  (define-key gnus-dired-mode-map "\C-c\C-m\C-s" 'gnus-dired-send-mbox))
 
 ;; FIXME: Make it customizable, change the default to `mail-user-agent' when
 ;; this file is renamed (e.g. to `dired-mime.el').
@@ -185,6 +188,64 @@ filenames."
 	(setq files-to-attach (cdr files-to-attach)))
       (message "Attached file(s) %s" files-str))))
 
+(defvar message-unix-mail-delimiter)	; quiet compiler
+(autoload 'gnus-alive-p "gnus-util")
+
+(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")
+
+(defun gnus-dired-map-over-mbox (function mbox-files)
+  "Call FUNCTION for each email in MBOX-FILES."
+  (require 'message)
+  (let (beg end email)
+    (dolist (m mbox-files)
+      (with-temp-buffer
+	(insert-file-contents m)
+	(while (re-search-forward message-unix-mail-delimiter nil t)
+	  (replace-match "")
+	  (setq beg (point))
+	  (if (re-search-forward message-unix-mail-delimiter nil t)
+	      (setq end (goto-char (match-beginning 0)))
+	    (setq end (point-max)))
+	  (setq email (buffer-substring beg end))
+	  (delete-region beg end)
+	  (with-temp-buffer
+	    (insert email)
+	    (goto-char (point-min))
+	    (re-search-forward "^$")
+	    (insert mail-header-separator)
+	    (funcall function)))))))
+
+(defun gnus-dired-import-mbox-as-draft (&rest mbox-files)
+  "Import emails in MBOX-FILES into the draft group."
+  (interactive (dired-get-marked-files))
+  (assert (gnus-alive-p) nil "Gnus is not running")
+  (gnus-agent-queue-setup "drafts")
+  (gnus-dired-map-over-mbox
+   (lambda ()
+     (nndraft-request-associate-buffer "drafts")
+     (save-buffer 0))
+   mbox-files))
+
+(defun gnus-dired-send-mbox (&rest mbox-files)
+  "Send all emails in MBOX-FILES."
+  (interactive (dired-get-marked-files))
+  (let (to-address)
+    (gnus-dired-map-over-mbox
+     (lambda ()
+       (message-mode)
+       (message-narrow-to-headers-or-head)
+       (unless (message-fetch-field "to")
+	 (unless to-address
+	   (setq to-address (read-string "To address: ")))
+	 (message-add-header (format "To: %s" to-address)))
+       (message-send))
+     mbox-files)))
+
 (autoload 'mailcap-parse-mailcaps "mailcap" "" t)
 
 (defun gnus-dired-find-file-mailcap (&optional file-name arg)
-- 
1.7.3


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Keep-dates-for-imported-drafts.patch --]
[-- Type: text/x-diff, Size: 2709 bytes --]

From 0392e38ad1e38461c9d275054af742c0fcc647de Mon Sep 17 00:00:00 2001
From: Leo <sdl.web@gmail.com>
Date: Tue, 20 Jul 2010 08:03:21 +0100
Subject: [PATCH 2/3] Keep dates for imported drafts

Add a meta header field X-Draft-Keep-Date for drafts imported from
mbox using gnus-dired.el. The header field Date can contain important
information for example 'git format-patch' uses it for commit date. We
don't want draft editing to overwrite it.
---
 lisp/gnus/gnus-dired.el |   18 +++++++++++++-----
 lisp/gnus/gnus-draft.el |    3 ++-
 lisp/gnus/message.el    |    2 +-
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/lisp/gnus/gnus-dired.el b/lisp/gnus/gnus-dired.el
index 9d8713c..cf2d177 100644
--- a/lisp/gnus/gnus-dired.el
+++ b/lisp/gnus/gnus-dired.el
@@ -225,11 +225,19 @@ filenames."
   (interactive (dired-get-marked-files))
   (assert (gnus-alive-p) nil "Gnus is not running")
   (gnus-agent-queue-setup "drafts")
-  (gnus-dired-map-over-mbox
-   (lambda ()
-     (nndraft-request-associate-buffer "drafts")
-     (save-buffer 0))
-   mbox-files))
+  (let (to-address)
+    (gnus-dired-map-over-mbox
+     (lambda ()
+       (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 (read-string "To address: ")))
+	 (message-add-header (format "To: %s" to-address)))
+       (save-buffer 0))
+     mbox-files)))
 
 (defun gnus-dired-send-mbox (&rest mbox-files)
   "Send all emails in MBOX-FILES."
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))
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
-- 
1.7.3


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-Read-emall-addresses-with-completion.patch --]
[-- Type: text/x-diff, Size: 3084 bytes --]

From 5cc4a9bdf491d9ef1ee4666467481bd106767b31 Mon Sep 17 00:00:00 2001
From: Leo <sdl.web@gmail.com>
Date: Fri, 30 Jul 2010 14:31:49 +0100
Subject: [PATCH 3/3] Read emall addresses with completion

New function gnus-dired-read-email that uses bbdb-complete-name if
available for email completion.

Support adding Cc addresses.
---
 lisp/gnus/gnus-dired.el |   32 ++++++++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/lisp/gnus/gnus-dired.el b/lisp/gnus/gnus-dired.el
index cf2d177..9abb2e7 100644
--- a/lisp/gnus/gnus-dired.el
+++ b/lisp/gnus/gnus-dired.el
@@ -198,6 +198,14 @@ filenames."
 (declare-function message-send "message")
 (declare-function message-narrow-to-headers-or-head "message")
 
+(defvar gnus-dired-read-email-map (make-sparse-keymap)
+  "Minibuffer keymap for `gnus-dired-read-email'.")
+(set-keymap-parent gnus-dired-read-email-map minibuffer-local-map)
+(when (fboundp 'bbdb-complete-name)
+  (define-key gnus-dired-read-email-map [tab] 'bbdb-complete-name))
+(defsubst gnus-dired-read-email (prompt)
+  (read-from-minibuffer prompt nil gnus-dired-read-email-map))
+
 (defun gnus-dired-map-over-mbox (function mbox-files)
   "Call FUNCTION for each email in MBOX-FILES."
   (require 'message)
@@ -225,7 +233,7 @@ filenames."
   (interactive (dired-get-marked-files))
   (assert (gnus-alive-p) nil "Gnus is not running")
   (gnus-agent-queue-setup "drafts")
-  (let (to-address)
+  (let (to-address cc-address)
     (gnus-dired-map-over-mbox
      (lambda ()
        (message-mode)
@@ -234,23 +242,39 @@ filenames."
        (nndraft-request-associate-buffer "drafts")
        (unless (message-fetch-field "to")
 	 (unless to-address
-	   (setq to-address (read-string "To address: ")))
+	   (setq to-address (gnus-dired-read-email "To: ")))
 	 (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? ")
+		     (gnus-dired-read-email "Cc: ")
+		   'no)))
+	 (unless (eq cc-address 'no)
+	   (message-add-header (format "Cc: %s" cc-address))))
        (save-buffer 0))
      mbox-files)))
 
 (defun gnus-dired-send-mbox (&rest mbox-files)
   "Send all emails in MBOX-FILES."
   (interactive (dired-get-marked-files))
-  (let (to-address)
+  (let (to-address cc-address)
     (gnus-dired-map-over-mbox
      (lambda ()
        (message-mode)
        (message-narrow-to-headers-or-head)
        (unless (message-fetch-field "to")
 	 (unless to-address
-	   (setq to-address (read-string "To address: ")))
+	   (setq to-address (gnus-dired-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? ")
+		     (gnus-dired-read-email "Cc: ")
+		   'no)))
+	 (unless (eq cc-address 'no)
+	   (message-add-header (format "Cc: %s" cc-address))))
        (message-send))
      mbox-files)))
 
-- 
1.7.3


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-16  6:09     ` Leo
@ 2010-12-16 10:01       ` Francis Moreau
  2010-12-16 13:07         ` Leo
  2010-12-16 15:53       ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 20+ messages in thread
From: Francis Moreau @ 2010-12-16 10:01 UTC (permalink / raw)
  To: Leo; +Cc: emacs-devel, ding, Thierry Volpiatto

Leo <sdl.web@gmail.com> 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.

> 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.

-- 
Francis



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-16 10:01       ` Francis Moreau
@ 2010-12-16 13:07         ` Leo
  2010-12-16 13:12           ` Leo
  2010-12-16 20:20           ` Francis Moreau
  0 siblings, 2 replies; 20+ messages in thread
From: Leo @ 2010-12-16 13:07 UTC (permalink / raw)
  To: Francis Moreau; +Cc: emacs-devel, ding, Thierry Volpiatto

[-- Attachment #1: Type: text/plain, Size: 3658 bytes --]

On 2010-12-16 10:01 +0000, Francis Moreau wrote:
> Leo <sdl.web@gmail.com> 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

[-- Attachment #2: gitmail.el --]
[-- Type: application/emacs-lisp, Size: 5793 bytes --]

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-16 13:07         ` Leo
@ 2010-12-16 13:12           ` Leo
  2010-12-16 20:20           ` Francis Moreau
  1 sibling, 0 replies; 20+ messages in thread
From: Leo @ 2010-12-16 13:12 UTC (permalink / raw)
  To: emacs-devel; +Cc: ding

On 2010-12-16 13:07 +0000, Leo wrote:
>   (interactive (if (derived-mode-p 'dired)

Sorry for the typo.

diff --git a/gitmail.el b/gitmail.el
index 71aadee..60551df 100644
--- a/gitmail.el
+++ b/gitmail.el
@@ -120,7 +120,7 @@
 ;;;###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)
+  (interactive (if (derived-mode-p 'dired-mode)
                    (dired-get-marked-files)
                  (file-expand-wildcards (read-file-name "Find mbox file: ") t)))
   (assert (gnus-alive-p) nil "Gnus is not running")
@@ -131,7 +131,7 @@
 ;;;###autoload
 (defun gitmail-send-mbox (&rest mbox-files)
   "Send all emails in MBOX-FILES."
-  (interactive (if (derived-mode-p 'dired)
+  (interactive (if (derived-mode-p 'dired-mode)
                    (dired-get-marked-files)
                  (file-expand-wildcards (read-file-name "Find mbox file: ") t)))
   (let (to-address cc-address)

-- 
Oracle is the new evil




^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-16  6:09     ` Leo
  2010-12-16 10:01       ` Francis Moreau
@ 2010-12-16 15:53       ` Lars Magne Ingebrigtsen
  2010-12-16 17:16         ` Leo
  1 sibling, 1 reply; 20+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-12-16 15:53 UTC (permalink / raw)
  To: ding; +Cc: emacs-devel

Leo <sdl.web@gmail.com> writes:

> I tweaked gnus-dired to support git-send-email (patches 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

Is this for git only, or a general VC mechanism?

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-16 15:53       ` Lars Magne Ingebrigtsen
@ 2010-12-16 17:16         ` Leo
  2010-12-16 17:19           ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 20+ messages in thread
From: Leo @ 2010-12-16 17:16 UTC (permalink / raw)
  To: ding; +Cc: emacs-devel

On 2010-12-16 15:53 +0000, Lars Magne Ingebrigtsen wrote:
> Leo <sdl.web@gmail.com> writes:
>
>> I tweaked gnus-dired to support git-send-email (patches 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
>
> Is this for git only, or a general VC mechanism?

It imports/sends any mbox files. So not related to any specific VC.

Cheers,
Leo




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-16 17:16         ` Leo
@ 2010-12-16 17:19           ` Lars Magne Ingebrigtsen
  2010-12-17  6:29             ` Štěpán Němec
  0 siblings, 1 reply; 20+ messages in thread
From: Lars Magne Ingebrigtsen @ 2010-12-16 17:19 UTC (permalink / raw)
  To: ding; +Cc: emacs-devel

Leo <sdl.web@gmail.com> writes:

>>> I tweaked gnus-dired to support git-send-email (patches 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
>>
>> Is this for git only, or a general VC mechanism?
>
> It imports/sends any mbox files. So not related to any specific VC.

Then the description of these commands is a bit misleading.  :-)

But the use case is that you have an entire mbox of messages, and you
want to send them all?

-- 
(domestic pets only, the antidote for overdose, milk.)
  larsi@gnus.org * Lars Magne Ingebrigtsen




^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-16 13:07         ` Leo
  2010-12-16 13:12           ` Leo
@ 2010-12-16 20:20           ` Francis Moreau
  1 sibling, 0 replies; 20+ messages in thread
From: Francis Moreau @ 2010-12-16 20:20 UTC (permalink / raw)
  To: Leo; +Cc: Thierry Volpiatto, ding, emacs-devel

Leo <sdl.web@gmail.com> writes:

> On 2010-12-16 10:01 +0000, Francis Moreau wrote:
>> Leo <sdl.web@gmail.com> 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

why making them Git specific like the command names suggest ?

I would actually do: 's/gitmail/gnus/'

>
> Editing drafts in Gnus resets the date so you need this small patch (or
> is there a butter way to handle this?):

I know almost nothing in elisp sorry, so I can't comment your patches.

However I would be interested to know what Gnus developpers think about
these new commands. I don't think that Gnus is currently able to import
a mbox file/buffer and make it a draft(s). Also your gnus-dired stuffs
seem interesting.

-- 
Francis



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-16 17:19           ` Lars Magne Ingebrigtsen
@ 2010-12-17  6:29             ` Štěpán Němec
  2010-12-17  7:33               ` Francis Moreau
  2010-12-18 20:34               ` Reiner Steib
  0 siblings, 2 replies; 20+ messages in thread
From: Štěpán Němec @ 2010-12-17  6:29 UTC (permalink / raw)
  To: ding, emacs-devel

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Leo <sdl.web@gmail.com> writes:
>
>>>> I tweaked gnus-dired to support git-send-email (patches 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
>>>
>>> Is this for git only, or a general VC mechanism?
>>
>> It imports/sends any mbox files. So not related to any specific VC.
>
> Then the description of these commands is a bit misleading.  :-)
>
> But the use case is that you have an entire mbox of messages, and you
> want to send them all?

Does Gnus have anything akin to Mutt's -H option?

  -H draft
   Specify a draft file which contains header and body to use to send a message.

I.e., you do `mutt -H <mboxfile>' and Mutt opens the file, you can edit
it the same as when composing a new message and then send it. Useful
e.g. when sending single patches produced by `git format-patch'.

  Štěpán



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-17  6:29             ` Štěpán Němec
@ 2010-12-17  7:33               ` Francis Moreau
  2010-12-18 20:34               ` Reiner Steib
  1 sibling, 0 replies; 20+ messages in thread
From: Francis Moreau @ 2010-12-17  7:33 UTC (permalink / raw)
  To: Štěpán Němec; +Cc: ding, emacs-devel

Štěpán Němec <stepnem@gmail.com> writes:

> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
>> Leo <sdl.web@gmail.com> writes:
>>
>>>>> I tweaked gnus-dired to support git-send-email (patches 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
>>>>
>>>> Is this for git only, or a general VC mechanism?
>>>
>>> It imports/sends any mbox files. So not related to any specific VC.
>>
>> Then the description of these commands is a bit misleading.  :-)
>>
>> But the use case is that you have an entire mbox of messages, and you
>> want to send them all?
>
> Does Gnus have anything akin to Mutt's -H option?
>
>   -H draft
>    Specify a draft file which contains header and body to use to send a message.
>

I don't think so and that's mostly the whole point of the discussion.

>
> I.e., you do `mutt -H <mboxfile>' and Mutt opens the file, you can
>edit
> it the same as when composing a new message and then send it. Useful
> e.g. when sending single patches produced by `git format-patch'.

I tried it and that's indeed what I'd like to have with Gnus.

Except that Gnus could do better I guess, since I believe it could
handle a mbox file embedding several patches... Perhaps it would be
interesting to create a /draft/ group like it's possible to create a
nndoc group.

Also it would be nice if we could create a draft (group) from a buffer
(not only from a file), that would avoid to use a temporary mbox file
which I find a bit awkward. For example with mutt:

      $ git format-patch --stdout HEAD~1 | mutt -H

Thanks
-- 
Francis



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-17  6:29             ` Štěpán Němec
  2010-12-17  7:33               ` Francis Moreau
@ 2010-12-18 20:34               ` Reiner Steib
  2010-12-19  6:50                 ` Štěpán Němec
  1 sibling, 1 reply; 20+ messages in thread
From: Reiner Steib @ 2010-12-18 20:34 UTC (permalink / raw)
  To: Štěpán Němec; +Cc: ding, emacs-devel

On Fri, Dec 17 2010, Štěpán Němec wrote:

> Does Gnus have anything akin to Mutt's -H option?
>
>   -H draft
>    Specify a draft file which contains header and body to use to send a message.
>
> I.e., you do `mutt -H <mboxfile>' and Mutt opens the file, you can edit
> it the same as when composing a new message and then send it.

I guess that
  C-x C-f /path/to/draft/file RET
  M-x message-mode RET
should do this, basically.

You'd need to replace the first empty line with
`mail-header-separator'.  For sending a multi-message buffer, there is
`message-send-form-letter'.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: Sending patch with Gnus
  2010-12-18 20:34               ` Reiner Steib
@ 2010-12-19  6:50                 ` Štěpán Němec
  0 siblings, 0 replies; 20+ messages in thread
From: Štěpán Němec @ 2010-12-19  6:50 UTC (permalink / raw)
  To: ding; +Cc: emacs-devel

Reiner Steib <reinersteib+gmane@imap.cc> writes:

> On Fri, Dec 17 2010, Štěpán Němec wrote:
>
>> Does Gnus have anything akin to Mutt's -H option?
>>
>>   -H draft
>>    Specify a draft file which contains header and body to use to send a message.
>>
>> I.e., you do `mutt -H <mboxfile>' and Mutt opens the file, you can edit
>> it the same as when composing a new message and then send it.
>
> I guess that
>   C-x C-f /path/to/draft/file RET
>   M-x message-mode RET
> should do this, basically.
>
> You'd need to replace the first empty line with
> `mail-header-separator'.  For sending a multi-message buffer, there is
> `message-send-form-letter'.

Yeah, that's probably as close as it gets, thanks. Still, given Gnus'
overwhelming feature set, it would make sense IMO to have something
ready-made (i.e. not requiring you to munge the message by hand, like
inserting the separators etc.).

  Štěpán



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2010-12-19  6:50 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <m2aak7m36y.fsf@gmail.com>
2010-12-15 19:21 ` Sending patch with Gnus Lars Magne Ingebrigtsen
2010-12-15 21:11   ` Thierry Volpiatto
2010-12-15 21:50     ` Francis Moreau
2010-12-15 21:54       ` Lars Magne Ingebrigtsen
2010-12-16  6:09     ` Leo
2010-12-16 10:01       ` Francis Moreau
2010-12-16 13:07         ` Leo
2010-12-16 13:12           ` Leo
2010-12-16 20:20           ` Francis Moreau
2010-12-16 15:53       ` Lars Magne Ingebrigtsen
2010-12-16 17:16         ` Leo
2010-12-16 17:19           ` Lars Magne Ingebrigtsen
2010-12-17  6:29             ` Štěpán Němec
2010-12-17  7:33               ` Francis Moreau
2010-12-18 20:34               ` Reiner Steib
2010-12-19  6:50                 ` Štěpán Němec
2010-12-15 21:27   ` Tassilo Horn
2010-12-15 21:41     ` Francis Moreau
2010-12-15 22:06       ` Tassilo Horn
2010-12-15 22:27         ` Francis Moreau

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.