[PATCH 4/4] Update NEWS for user.other_name
[notmuch-archives.git] / e3 / 7a3b230b6ea8a19e69c7ec3ee65868ecfde923
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 5503A431FD0\r
6         for <notmuch@notmuchmail.org>; Sat, 16 Jul 2011 11:41:29 -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 0VQX-qLhOtZH for <notmuch@notmuchmail.org>;\r
16         Sat, 16 Jul 2011 11:41:28 -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 94C43431FB6\r
19         for <notmuch@notmuchmail.org>; Sat, 16 Jul 2011 11:41:28 -0700 (PDT)\r
20 Received: by marcos.anarcat.ath.cx (Postfix, from userid 1000)\r
21         id 3E71F7621D; Sat, 16 Jul 2011 14:41:28 -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 2/2] add edit function to resume postponed emails\r
25 Date: Sat, 16 Jul 2011 14:41:25 -0400\r
26 Message-Id: <1310841685-29167-1-git-send-email-anarcat@koumbit.org>\r
27 X-Mailer: git-send-email 1.7.5.4\r
28 In-Reply-To: <1310807540-29960-1-git-send-email-anarcat@koumbit.org>\r
29 References: <1310807540-29960-1-git-send-email-anarcat@koumbit.org>\r
30 MIME-Version: 1.0\r
31 Content-Type: text/plain; charset=UTF-8\r
32 Content-Transfer-Encoding: 8bit\r
33 Cc: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@koumbit.org>\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.13\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38         <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
40         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sat, 16 Jul 2011 18:41:29 -0000\r
47 \r
48 Add a new function to allow editing a new message starting from an\r
49 existing one, roughly the equivalent of Mutt's resend-message\r
50 functionality.\r
51 \r
52 Hooks into the search and show views through the "e" keybinding.\r
53 \r
54 "draft" tag is removed after the email is sent and the target thread\r
55 is marked as deleted.\r
56 \r
57 Known issues:\r
58 \r
59  1. only the first MIME part of the email is used\r
60  2. running this on a thread with more than one message has not been\r
61  tested\r
62  3. encoding is broken when files are reloaded, because we don't parse\r
63  MIME back\r
64  4. draft files are left around when mails are written, even if they\r
65  are not postponed\r
66 \r
67 Todo:\r
68 \r
69  1. use the proper gnus hooks to resume emails:\r
70  https://www.gnu.org/software/emacs/manual/html_node/message/Message-Actions.html#index-message_002dpostpone_002dactions-334\r
71 \r
72  2. write tests\r
73 \r
74 Signed-off-by: Antoine Beaupré <anarcat@koumbit.org>\r
75 ---\r
76  emacs/notmuch-mua.el  |   50 +++++++++++++++++++++++++++++++++++++++++++++++++\r
77  emacs/notmuch-show.el |    6 +++++\r
78  emacs/notmuch.el      |    7 ++++++\r
79  3 files changed, 63 insertions(+), 0 deletions(-)\r
80 \r
81 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
82 index 274c5da..11d014d 100644\r
83 --- a/emacs/notmuch-mua.el\r
84 +++ b/emacs/notmuch-mua.el\r
85 @@ -201,6 +201,56 @@ the From: address first."\r
86            (list (cons 'from (notmuch-mua-prompt-for-sender))))))\r
87      (notmuch-mua-mail nil nil other-headers)))\r
88  \r
89 +(defun notmuch-mua-delete-postponed (query-string)\r
90 +  "Delete postponed mail after sending."\r
91 +  (notmuch-tag query-string "+deleted")\r
92 +  (notmuch-tag query-string "-draft")\r
93 +)\r
94 +\r
95 +(defun notmuch-mua-edit-mail (query-string)\r
96 +  "Create a new mail composition window based on the current mail."\r
97 +  (interactive)\r
98 +  (let (headers\r
99 +       body\r
100 +       (args '("show" "--format=raw")))\r
101 +    (if notmuch-show-process-crypto\r
102 +       (setq args (append args '("--decrypt"))))\r
103 +    (setq args (append args (list query-string)))\r
104 +    ;; This make assumptions about the output of `notmuch show', but\r
105 +    ;; really only that the headers come first followed by a blank\r
106 +    ;; line and then the body.\r
107 +    (with-temp-buffer\r
108 +      (apply 'call-process (append (list notmuch-command nil (list t t) nil) args))\r
109 +      (goto-char (point-min))\r
110 +      (if (re-search-forward "^$" nil t)\r
111 +         (save-excursion\r
112 +           (save-restriction\r
113 +             (narrow-to-region (point-min) (point))\r
114 +             (goto-char (point-min))\r
115 +             (setq headers (mail-header-extract))))\r
116 +         )\r
117 +      (forward-line 1)\r
118 +      (setq body (buffer-substring (point) (point-max)))\r
119 +      )\r
120 +\r
121 +    (let ((message-signature nil))\r
122 +      (notmuch-mua-mail (mail-header 'to headers)\r
123 +                       (mail-header 'subject headers)\r
124 +                       (message-headers-to-generate headers t '(to subject))\r
125 +                       t nil nil (notmuch-mua-delete-postponed query-string))\r
126 +    )\r
127 +\r
128 +    ;; insert the message body - but put it in front of the signature\r
129 +    ;; if one is present\r
130 +    (goto-char (point-max))\r
131 +    (if (re-search-backward message-signature-separator nil t)\r
132 +         (forward-line -1)\r
133 +      (goto-char (point-max)))\r
134 +    (insert body))\r
135 +  (set-buffer-modified-p nil)\r
136 +\r
137 +  (message-goto-body))\r
138 +\r
139  (defun notmuch-mua-new-forward-message (&optional prompt-for-sender)\r
140    "Invoke the notmuch message forwarding window.\r
141  \r
142 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
143 index c83b992..1efde1c 100644\r
144 --- a/emacs/notmuch-show.el\r
145 +++ b/emacs/notmuch-show.el\r
146 @@ -865,6 +865,7 @@ function is used. "\r
147         (define-key map "m" 'notmuch-mua-new-mail)\r
148         (define-key map "f" 'notmuch-show-forward-message)\r
149         (define-key map "r" 'notmuch-show-reply)\r
150 +       (define-key map "e" 'notmuch-show-edit)\r
151         (define-key map "|" 'notmuch-show-pipe-message)\r
152         (define-key map "w" 'notmuch-show-save-attachments)\r
153         (define-key map "V" 'notmuch-show-view-raw-message)\r
154 @@ -1165,6 +1166,11 @@ any effects from previous calls to\r
155    (interactive "P")\r
156    (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender))\r
157  \r
158 +(defun notmuch-show-edit ()\r
159 +  "Edit the current message as new."\r
160 +  (interactive)\r
161 +  (notmuch-mua-edit-mail (notmuch-show-get-message-id)))\r
162 +\r
163  (defun notmuch-show-forward-message (&optional prompt-for-sender)\r
164    "Forward the current message."\r
165    (interactive "P")\r
166 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
167 index f6fb07b..b522715 100644\r
168 --- a/emacs/notmuch.el\r
169 +++ b/emacs/notmuch.el\r
170 @@ -204,6 +204,7 @@ For a mouse binding, return nil."\r
171      (define-key map "p" 'notmuch-search-previous-thread)\r
172      (define-key map "n" 'notmuch-search-next-thread)\r
173      (define-key map "r" 'notmuch-search-reply-to-thread)\r
174 +    (define-key map "e" 'notmuch-search-edit)\r
175      (define-key map "m" 'notmuch-mua-new-mail)\r
176      (define-key map "s" 'notmuch-search)\r
177      (define-key map "o" 'notmuch-search-toggle-order)\r
178 @@ -449,6 +450,12 @@ Complete list of currently available key bindings:\r
179    (let ((message-id (notmuch-search-find-thread-id)))\r
180      (notmuch-mua-new-reply message-id prompt-for-sender)))\r
181  \r
182 +(defun notmuch-search-edit ()\r
183 +  "Edit the current message as new."\r
184 +  (interactive)\r
185 +  (let ((message-id (notmuch-search-find-thread-id)))\r
186 +    (notmuch-mua-edit-mail message-id)))\r
187 +\r
188  (defun notmuch-call-notmuch-process (&rest args)\r
189    "Synchronously invoke \"notmuch\" with the given list of arguments.\r
190  \r
191 -- \r
192 1.7.5.4\r
193 \r