Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / 08 / adbe2df6d526507a3612bc19980b564e056195
1 Return-Path: <dme@dme.org>\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 D5EB76DE09ED\r
6  for <notmuch@notmuchmail.org>; Sat,  6 Feb 2016 11:24:27 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.171\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.171 tagged_above=-999 required=5 tests=[AWL=0.238, \r
12  DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7,\r
13  RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_NEUTRAL=0.652,\r
14  UNPARSEABLE_RELAY=0.001] autolearn=disabled\r
15 Received: from arlo.cworth.org ([127.0.0.1])\r
16  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
17  with ESMTP id dBC6hnANEcRa for <notmuch@notmuchmail.org>;\r
18  Sat,  6 Feb 2016 11:24:25 -0800 (PST)\r
19 Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com\r
20  [74.125.82.66]) by arlo.cworth.org (Postfix) with ESMTPS id 623166DE0B25 for\r
21  <notmuch@notmuchmail.org>; Sat,  6 Feb 2016 11:24:25 -0800 (PST)\r
22 Received: by mail-wm0-f66.google.com with SMTP id 128so8517430wmz.3\r
23  for <notmuch@notmuchmail.org>; Sat, 06 Feb 2016 11:24:25 -0800 (PST)\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
25  d=dme-org.20150623.gappssmtp.com; s=20150623;\r
26  h=from:to:subject:date:message-id:in-reply-to:references;\r
27  bh=7p3ufQXjlDwLNzox++RAkNzH/ySW2+srx60RBLJFVLM=;\r
28  b=uKSodKKCNE9YzoFPo1Fvqi6lpS5Yu7lVNL15jo9XsBfzHu3hw2YjnkAFDdQ8GLJsYh\r
29  fUWP/3TgcKvVCdgvEflgdURZ8pnCWiunrSWQmSv3hOG0PbO0qV3T7wcQFNP3Z3VUKxO3\r
30  XeguE1oePJpK4cO+kFfCrSlbU2TAHfX37mjrhzGJoNmzdj58kwRm5DGj222Vrgk03SDo\r
31  4gix6dU5TLc7R/0BL3Klk5nxTtqoy/qgspeOV35ql1S6LvkNh0XIFeZnxex2TcCbgVor\r
32  wbsuAenVPXdkWi6o9PyUO5rHUukAcRuKHNThoj2VamtBYq6o7c1P0ZlfPGl67cOJPmtm\r
33  tsZg==\r
34 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
35  d=1e100.net; s=20130820;\r
36  h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to\r
37  :references;\r
38  bh=7p3ufQXjlDwLNzox++RAkNzH/ySW2+srx60RBLJFVLM=;\r
39  b=gVc3ie/hYZAh6tBdfgx2WDMZ5lgXWckzDqq9rIgyuj0xQGNQ0DgG3hNCu7Eez1sH3m\r
40  dJGzT6T06QrkfnG49MBOmZvOlMYiuXd4/Wk7MWirB40E3u1viRZL9tZ49t3Cecu4yx1T\r
41  Oedw8oA/JXrvHMhbKD9Yyu6YtIAfHdd2ocJV54NNR5RaS8Fw0JXcRf456aut1zPneYmv\r
42  hmx3wshhtsIyr/6MEI+ZqIzoQFgsaPXfyUlkRGDGy0bvrwSo39dB7TiqWjONKvYedXKV\r
43  aAh0LM9A4hoT+W3s5bZx08UT0oGkDMuxMhaY2dymuAzejQjSdsdoNZvdMWXizvjoVvE2\r
44  mtOg==\r
45 X-Gm-Message-State:\r
46  AG10YOQLGimfu5e4gyaM2yL39WsvF7qgV4uVyV2Y+tYuuXNQ29U5pWO9WeMPUa1mCH6ZPw==\r
47 X-Received: by 10.28.9.71 with SMTP id 68mr22323709wmj.33.1454786663702;\r
48  Sat, 06 Feb 2016 11:24:23 -0800 (PST)\r
49 Received: from disaster-area.hh.sledj.net\r
50  ([2a01:348:1a2:1:ea39:35ff:fe2c:a227])\r
51  by smtp.gmail.com with ESMTPSA id q75sm4510195wmd.6.2016.02.06.11.24.22\r
52  for <notmuch@notmuchmail.org>\r
53  (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
54  Sat, 06 Feb 2016 11:24:22 -0800 (PST)\r
55 Received: from localhost (disaster-area.hh.sledj.net [local])\r
56  by disaster-area.hh.sledj.net (OpenSMTPD) with ESMTPA id 867e8815\r
57  for <notmuch@notmuchmail.org>; Sat, 6 Feb 2016 19:24:19 +0000 (UTC)\r
58 From: David Edmondson <dme@dme.org>\r
59 To: notmuch@notmuchmail.org\r
60 Subject: [PATCH v1] emacs: Add `notmuch-show-forward-open-messages'.\r
61 Date: Sat,  6 Feb 2016 19:24:19 +0000\r
62 Message-Id: <1454786659-3615-2-git-send-email-dme@dme.org>\r
63 X-Mailer: git-send-email 2.1.4\r
64 In-Reply-To: <1454786659-3615-1-git-send-email-dme@dme.org>\r
65 References: <1454786659-3615-1-git-send-email-dme@dme.org>\r
66 X-BeenThere: notmuch@notmuchmail.org\r
67 X-Mailman-Version: 2.1.20\r
68 Precedence: list\r
69 List-Id: "Use and development of the notmuch mail system."\r
70  <notmuch.notmuchmail.org>\r
71 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
72  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
73 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
74 List-Post: <mailto:notmuch@notmuchmail.org>\r
75 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
76 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
77  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
78 X-List-Received-Date: Sat, 06 Feb 2016 19:24:28 -0000\r
79 \r
80 Add a function to forward all open messages in the current view of a\r
81 thread. Bind this to "F".\r
82 ---\r
83  emacs/notmuch-mua.el  | 48 ++++++++++++++++++++++++++++++++++++++++++++++++\r
84  emacs/notmuch-show.el | 11 +++++++++++\r
85  2 files changed, 59 insertions(+)\r
86 \r
87 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
88 index 5462f54..be2967f 100644\r
89 --- a/emacs/notmuch-mua.el\r
90 +++ b/emacs/notmuch-mua.el\r
91 @@ -425,6 +425,54 @@ the From: address first."\r
92      (message-hide-headers)\r
93      (set-buffer-modified-p nil)))\r
94  \r
95 +(defun notmuch-mua-new-forward-messages (messages &optional prompt-for-sender)\r
96 +  "Compose a new message forwarding MESSAGES.\r
97 +\r
98 +If PROMPT-FOR-SENDER is non-nil, the user will be prompteed for\r
99 +the From: address."\r
100 +  (let* ((other-headers\r
101 +         (when (or prompt-for-sender notmuch-always-prompt-for-sender)\r
102 +           (list (cons 'From (notmuch-mua-prompt-for-sender)))))\r
103 +        forward-subject) ;; Comes from the first message and is\r
104 +                         ;; applied later.\r
105 +\r
106 +    ;; Generate the template for the outgoing message.\r
107 +    (notmuch-mua-mail nil "" other-headers nil (notmuch-mua-get-switch-function))\r
108 +\r
109 +    (save-excursion\r
110 +      ;; Insert all of the forwarded messages.\r
111 +      (mapc (lambda (id)\r
112 +             (let ((temp-buffer (get-buffer-create\r
113 +                                 (concat "*notmuch-fwd-raw-" id "*"))))\r
114 +               ;; Get the raw version of this message in the buffer.\r
115 +               (with-current-buffer temp-buffer\r
116 +                 (erase-buffer)\r
117 +                 (let ((coding-system-for-read 'no-conversion))\r
118 +                   (call-process notmuch-command nil t nil "show" "--format=raw" id))\r
119 +                 ;; Because we process the messages in reverse order,\r
120 +                 ;; always generate a forwarded subject, then use the\r
121 +                 ;; last (i.e. first) one.\r
122 +                 (setq forward-subject (message-make-forward-subject)))\r
123 +               ;; Make a copy ready to be forwarded in the\r
124 +               ;; composition buffer.\r
125 +               (message-forward-make-body temp-buffer)\r
126 +               ;; Kill the temporary buffer.\r
127 +               (kill-buffer temp-buffer)))\r
128 +           ;; `message-forward-make-body' always puts the message at\r
129 +           ;; the top, so do them in reverse order.\r
130 +           (reverse messages))\r
131 +\r
132 +      ;; Add in the appropriate subject.\r
133 +      (save-restriction\r
134 +       (message-narrow-to-headers)\r
135 +       (message-remove-header "Subject")\r
136 +       (message-add-header (concat "Subject: " forward-subject)))\r
137 +\r
138 +      ;; `message-forward-make-body' shows the User-agent header.  Hide\r
139 +      ;; it again.\r
140 +      (message-hide-headers)\r
141 +      (set-buffer-modified-p nil))))))\r
142 +\r
143  (defun notmuch-mua-new-reply (query-string &optional prompt-for-sender reply-all)\r
144    "Compose a reply to the message identified by QUERY-STRING.\r
145  \r
146 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
147 index 3345878..a8c6f1e 100644\r
148 --- a/emacs/notmuch-show.el\r
149 +++ b/emacs/notmuch-show.el\r
150 @@ -1371,6 +1371,7 @@ reset based on the original query."\r
151      (define-key map (kbd "<backtab>") 'notmuch-show-previous-button)\r
152      (define-key map (kbd "TAB") 'notmuch-show-next-button)\r
153      (define-key map "f" 'notmuch-show-forward-message)\r
154 +    (define-key map "F" 'notmuch-show-forward-open-messages)\r
155      (define-key map "l" 'notmuch-show-filter-thread)\r
156      (define-key map "r" 'notmuch-show-reply-sender)\r
157      (define-key map "R" 'notmuch-show-reply)\r
158 @@ -1798,6 +1799,16 @@ any effects from previous calls to\r
159    (with-current-notmuch-show-message\r
160     (notmuch-mua-new-forward-message prompt-for-sender)))\r
161  \r
162 +(put 'notmuch-show-forward-open-messages 'notmuch-prefix-doc\r
163 +     "... and prompt for sender")\r
164 +(defun notmuch-show-forward-open-messages (&optional prompt-for-sender)\r
165 +  "Forward the currently open messages."\r
166 +  (interactive "P")\r
167 +  (let ((open-messages (notmuch-show-get-message-ids-for-open-messages)))\r
168 +    (unless open-messages\r
169 +      (error "No open messages to forward."))\r
170 +    (notmuch-mua-new-forward-messages open-messages prompt-for-sender)))\r
171 +\r
172  (defun notmuch-show-next-message (&optional pop-at-end)\r
173    "Show the next message.\r
174  \r
175 -- \r
176 2.1.4\r
177 \r