[PATCH 1/2] emacs: add function to resend message to new recipients
[notmuch-archives.git] / ab / b767816d9fa8f970098d4b2f67150ff99aa597
1 Return-Path: <too@guru-group.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id 3C6366DE02A9\r
6  for <notmuch@notmuchmail.org>; Sat,  7 May 2016 12:03:27 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.268\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.268 tagged_above=-999 required=5 tests=[AWL=0.277, \r
12  HEADER_FROM_DIFFERENT_DOMAINS=0.001, T_RP_MATCHES_RCVD=-0.01]\r
13  autolearn=disabled\r
14 Received: from arlo.cworth.org ([127.0.0.1])\r
15  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
16  with ESMTP id SxShrm-72dVw for <notmuch@notmuchmail.org>;\r
17  Sat,  7 May 2016 12:03:18 -0700 (PDT)\r
18 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
19  by arlo.cworth.org (Postfix) with ESMTP id 3672A6DE026C\r
20  for <notmuch@notmuchmail.org>; Sat,  7 May 2016 12:03:17 -0700 (PDT)\r
21 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
22  id 15DD9100232; Sat,  7 May 2016 22:03:15 +0300 (EEST)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: notmuch@notmuchmail.org\r
25 Cc: tomi.ollila@iki.fi\r
26 Subject: [PATCH 1/2] emacs: add function to resend message to new recipients\r
27 Date: Sat,  7 May 2016 22:03:11 +0300\r
28 Message-Id: <1462647792-25427-2-git-send-email-tomi.ollila@iki.fi>\r
29 X-Mailer: git-send-email 2.6.4\r
30 In-Reply-To: <1462647792-25427-1-git-send-email-tomi.ollila@iki.fi>\r
31 References: <1462647792-25427-1-git-send-email-tomi.ollila@iki.fi>\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.20\r
34 Precedence: list\r
35 List-Id: "Use and development of the notmuch mail system."\r
36  <notmuch.notmuchmail.org>\r
37 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
38  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
40 List-Post: <mailto:notmuch@notmuchmail.org>\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
42 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
43  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
44 X-List-Received-Date: Sat, 07 May 2016 19:03:27 -0000\r
45 \r
46 The new function notmuch-show-message-resend re-sends\r
47 message to new recipients using #'message-resend.\r
48 \r
49 Recipients are read from minibuffer as a comma-separated\r
50 string (with some keyboard support including tab completion).\r
51 \r
52 Final confirmation before sending is asked.\r
53 ---\r
54  emacs/notmuch-address.el | 19 +++++++++++++++++++\r
55  emacs/notmuch-show.el    |  8 ++++++++\r
56  2 files changed, 27 insertions(+)\r
57 \r
58 diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
59 index aafbe5fb8328..8b79d3402184 100644\r
60 --- a/emacs/notmuch-address.el\r
61 +++ b/emacs/notmuch-address.el\r
62 @@ -249,6 +249,25 @@ (defun notmuch-address-harvest-trigger ()\r
63  \r
64  ;;\r
65  \r
66 +(defun notmuch-address-from-minibuffer (prompt)\r
67 +  (if (not notmuch-address-command)\r
68 +      (read-string prompt)\r
69 +    (let ((rmap (copy-keymap minibuffer-local-map))\r
70 +         (omap minibuffer-local-map))\r
71 +      ;; Configure TAB to start completion when executing read-string.\r
72 +      ;; "Original" minibuffer keymap is restored just before calling\r
73 +      ;; notmuch-address-expand-name as it may also use minibuffer-local-map\r
74 +      ;; (completing-read probably does not but if something else is used there).\r
75 +      (define-key rmap (kbd "TAB") (lambda ()\r
76 +                                    (interactive)\r
77 +                                    (let ((enable-recursive-minibuffers t)\r
78 +                                          (minibuffer-local-map omap))\r
79 +                                      (notmuch-address-expand-name))))\r
80 +      (let ((minibuffer-local-map rmap))\r
81 +       (read-string prompt)))))\r
82 +\r
83 +;;\r
84 +\r
85  (provide 'notmuch-address)\r
86  \r
87  ;;; notmuch-address.el ends here\r
88 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
89 index 5d9b7b45c557..4b8c66fdb2a1 100644\r
90 --- a/emacs/notmuch-show.el\r
91 +++ b/emacs/notmuch-show.el\r
92 @@ -1855,6 +1855,14 @@ (defun notmuch-show-forward-open-messages (&optional prompt-for-sender)\r
93        (error "No open messages to forward."))\r
94      (notmuch-mua-new-forward-messages open-messages prompt-for-sender)))\r
95  \r
96 +(defun notmuch-show-resend-message (addresses)\r
97 +  "Resend the current message."\r
98 +  (interactive (list (notmuch-address-from-minibuffer "Resend to: ")))\r
99 +  (when (y-or-n-p (concat "Confirm resend to " addresses " "))\r
100 +    (notmuch-show-view-raw-message)\r
101 +    (message-resend addresses)\r
102 +    (notmuch-bury-or-kill-this-buffer)))\r
103 +\r
104  (defun notmuch-show-next-message (&optional pop-at-end)\r
105    "Show the next message.\r
106  \r
107 -- \r
108 2.6.4\r
109 \r