[PATCH 4/4] Update NEWS for user.other_name
[notmuch-archives.git] / ed / 79ab7cf30aba70493e179dc21515319b8a2f93
1 Return-Path: <anarcat@anarcat.ath.cx>\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 olra.theworths.org (Postfix) with ESMTP id 35DC9431FD0\r
6         for <notmuch@notmuchmail.org>; Sat, 16 Jul 2011 02:12:37 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id e0RTjClDWT8f for <notmuch@notmuchmail.org>;\r
16         Sat, 16 Jul 2011 02:12:35 -0700 (PDT)\r
17 Received: from marcos.anarcat.ath.cx (H144.C72.B0.tor.eicat.ca [72.0.72.144])\r
18         by olra.theworths.org (Postfix) with ESMTP id 6E04B431FB6\r
19         for <notmuch@notmuchmail.org>; Sat, 16 Jul 2011 02:12:35 -0700 (PDT)\r
20 Received: by marcos.anarcat.ath.cx (Postfix, from userid 1000)\r
21         id A48652BC47; Sat, 16 Jul 2011 05:12:34 -0400 (EDT)\r
22 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@koumbit.org>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [PATCH] add edit function to resume postponed emails\r
25 Date: Sat, 16 Jul 2011 05:12:20 -0400\r
26 Message-Id: <1310807540-29960-1-git-send-email-anarcat@koumbit.org>\r
27 X-Mailer: git-send-email 1.7.5.4\r
28 MIME-Version: 1.0\r
29 Content-Type: text/plain; charset=UTF-8\r
30 Content-Transfer-Encoding: 8bit\r
31 Cc: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@koumbit.org>\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.13\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: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
44 X-List-Received-Date: Sat, 16 Jul 2011 09:12:37 -0000\r
45 \r
46 Add a new function to allow editing a new message starting from an\r
47 existing one, roughly the equivalent of Mutt's resend-message\r
48 functionality.\r
49 \r
50 Hooks into the search and show views through the "e" keybinding.\r
51 \r
52 "postponed" tag is removed after the email is sent and the target thread\r
53 is marked as deleted.\r
54 \r
55 Known issues:\r
56 \r
57  1. only the first MIME part of the email is used\r
58  2. running this on a thread with more than one message has not been\r
59  tested\r
60 \r
61 Signed-off-by: Antoine Beaupré <anarcat@koumbit.org>\r
62 ---\r
63  emacs/notmuch-mua.el  |   51 +++++++++++++++++++++++++++++++++++++++++++++++++\r
64  emacs/notmuch-show.el |    6 +++++\r
65  emacs/notmuch.el      |    7 ++++++\r
66  3 files changed, 64 insertions(+), 0 deletions(-)\r
67 \r
68 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
69 index 274c5da..83d7d2b 100644\r
70 --- a/emacs/notmuch-mua.el\r
71 +++ b/emacs/notmuch-mua.el\r
72 @@ -201,6 +201,57 @@ the From: address first."\r
73            (list (cons 'from (notmuch-mua-prompt-for-sender))))))\r
74      (notmuch-mua-mail nil nil other-headers)))\r
75  \r
76 +(defun notmuch-mua-delete-postponed (query-string)\r
77 +  "Delete postponed mail after sending."\r
78 +  (notmuch-tag query-string "+delete")\r
79 +  (notmuch-tag query-string "-postponed")\r
80 +)\r
81 +\r
82 +(defun notmuch-mua-edit-mail (query-string)\r
83 +  "Create a new mail composition window based on the current mail."\r
84 +  (interactive)\r
85 +  (let (headers\r
86 +       body\r
87 +       (args '("show" "--format=raw")))\r
88 +    (if notmuch-show-process-crypto\r
89 +       (setq args (append args '("--decrypt"))))\r
90 +    (setq args (append args (list query-string)))\r
91 +    ;; This make assumptions about the output of `notmuch show', but\r
92 +    ;; really only that the headers come first followed by a blank\r
93 +    ;; line and then the body.\r
94 +    (with-temp-buffer\r
95 +      (apply 'call-process (append (list notmuch-command nil (list t t) nil) args))\r
96 +      (goto-char (point-min))\r
97 +      (if (re-search-forward "^$" nil t)\r
98 +         (save-excursion\r
99 +           (save-restriction\r
100 +             (narrow-to-region (point-min) (point))\r
101 +             (goto-char (point-min))\r
102 +             (setq headers (mail-header-extract))))\r
103 +         )\r
104 +      (forward-line 1)\r
105 +      (setq body (buffer-substring (point) (point-max)))\r
106 +      )\r
107 +\r
108 +    (let ((message-signature nil))\r
109 +      (notmuch-mua-mail (mail-header 'to headers)\r
110 +                       (mail-header 'subject headers)\r
111 +                       (message-headers-to-generate headers t '(to subject))\r
112 +                       t nil nil (notmuch-mua-delete-postponed query-string))\r
113 +    )\r
114 +\r
115 +    ;; insert the message body - but put it in front of the signature\r
116 +    ;; if one is present\r
117 +    (goto-char (point-max))\r
118 +    (if (re-search-backward message-signature-separator nil t)\r
119 +         (forward-line -1)\r
120 +      (goto-char (point-max)))\r
121 +    (insert body))\r
122 +  (set-buffer-modified-p nil)\r
123 +\r
124 +  (message-goto-body))\r
125 +)\r
126 +\r
127  (defun notmuch-mua-new-forward-message (&optional prompt-for-sender)\r
128    "Invoke the notmuch message forwarding window.\r
129  \r
130 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
131 index f96743b..3698767 100644\r
132 --- a/emacs/notmuch-show.el\r
133 +++ b/emacs/notmuch-show.el\r
134 @@ -865,6 +865,7 @@ function is used. "\r
135         (define-key map "m" 'notmuch-mua-new-mail)\r
136         (define-key map "f" 'notmuch-show-forward-message)\r
137         (define-key map "r" 'notmuch-show-reply)\r
138 +       (define-key map "e" 'notmuch-show-edit)\r
139         (define-key map "|" 'notmuch-show-pipe-message)\r
140         (define-key map "w" 'notmuch-show-save-attachments)\r
141         (define-key map "V" 'notmuch-show-view-raw-message)\r
142 @@ -1164,6 +1165,11 @@ any effects from previous calls to\r
143    (interactive "P")\r
144    (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender))\r
145  \r
146 +(defun notmuch-show-edit ()\r
147 +  "Edit the current message as new."\r
148 +  (interactive)\r
149 +  (notmuch-mua-edit-mail (notmuch-show-get-message-id)))\r
150 +\r
151  (defun notmuch-show-forward-message (&optional prompt-for-sender)\r
152    "Forward the current message."\r
153    (interactive "P")\r
154 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
155 index f11ec24..f18b739 100644\r
156 --- a/emacs/notmuch.el\r
157 +++ b/emacs/notmuch.el\r
158 @@ -204,6 +204,7 @@ For a mouse binding, return nil."\r
159      (define-key map "p" 'notmuch-search-previous-thread)\r
160      (define-key map "n" 'notmuch-search-next-thread)\r
161      (define-key map "r" 'notmuch-search-reply-to-thread)\r
162 +    (define-key map "e" 'notmuch-search-edit)\r
163      (define-key map "m" 'notmuch-mua-new-mail)\r
164      (define-key map "s" 'notmuch-search)\r
165      (define-key map "o" 'notmuch-search-toggle-order)\r
166 @@ -448,6 +449,12 @@ Complete list of currently available key bindings:\r
167    (let ((message-id (notmuch-search-find-thread-id)))\r
168      (notmuch-mua-new-reply message-id prompt-for-sender)))\r
169  \r
170 +(defun notmuch-search-edit ()\r
171 +  "Edit the current message as new."\r
172 +  (interactive)\r
173 +  (let ((message-id (notmuch-search-find-thread-id)))\r
174 +    (notmuch-mua-edit-mail message-id)))\r
175 +\r
176  (defun notmuch-call-notmuch-process (&rest args)\r
177    "Synchronously invoke \"notmuch\" with the given list of arguments.\r
178  \r
179 -- \r
180 1.7.5.4\r
181 \r