From: Leo <sdl.web@gmail.com>
To: Thierry Volpiatto <thierry.volpiatto@gmail.com>
Cc: ding@gnus.org, emacs-devel@gnu.org
Subject: Re: Sending patch with Gnus
Date: Thu, 16 Dec 2010 06:09:34 +0000 [thread overview]
Message-ID: <m1y67q8d0h.fsf@cam.ac.uk> (raw)
In-Reply-To: <871v5i212s.fsf@tux.homenetwork> (Thierry Volpiatto's message of "Wed, 15 Dec 2010 22:11:39 +0100")
[-- 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
next prev parent reply other threads:[~2010-12-16 6:09 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-15 16:05 Francis Moreau
2010-12-15 19:21 ` 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-15 22:13 ` Francis Moreau
2010-12-16 6:09 ` Leo [this message]
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-17 0:53 ` Rupert Swarbrick
2010-12-17 1:03 ` "Purging" nndoc group, was: " Rupert Swarbrick
2010-12-17 7:52 ` Francis Moreau
2010-12-17 8:02 ` Rupert Swarbrick
2010-12-17 8:14 ` Francis Moreau
2010-12-17 16:30 ` Lars Magne Ingebrigtsen
2010-12-17 19:54 ` Francis Moreau
2010-12-17 19:57 ` Lars Magne Ingebrigtsen
2010-12-17 20:04 ` Francis Moreau
2010-12-17 20:14 ` Štěpán Němec
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-17 10:01 ` Leo
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1y67q8d0h.fsf@cam.ac.uk \
--to=sdl.web@gmail.com \
--cc=ding@gnus.org \
--cc=emacs-devel@gnu.org \
--cc=thierry.volpiatto@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).