Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / e8 / a4f4d102bc958bdba5751b62c1768e9636c3a8
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 F1BA76DE0B25\r
6  for <notmuch@notmuchmail.org>; Sat,  6 Feb 2016 13:08:05 -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.86\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.86 tagged_above=-999 required=5 tests=[AWL=0.927,\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 buWQRkWQwhe0 for <notmuch@notmuchmail.org>;\r
18  Sat,  6 Feb 2016 13:08:03 -0800 (PST)\r
19 Received: from mail-wm0-f45.google.com (mail-wm0-f45.google.com\r
20  [74.125.82.45]) by arlo.cworth.org (Postfix) with ESMTPS id 7004C6DE09ED for\r
21  <notmuch@notmuchmail.org>; Sat,  6 Feb 2016 13:08:03 -0800 (PST)\r
22 Received: by mail-wm0-f45.google.com with SMTP id g62so70083658wme.0\r
23  for <notmuch@notmuchmail.org>; Sat, 06 Feb 2016 13:08:03 -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=cWrzPHKPzDYzYSpCdk11INHKUFp505G3llR/23UKoJZOLgTwHRs/TNPRVUXvJgt+Mx\r
29  LziJNHXpp64LFNvdewC3cNG36QV1n2kvc+9fl4IIyk8tuMk86YX8yloDeshGTdvGNZ2k\r
30  VbM7wh9p4uwJLcjVlGSCNr9iU5sLYAh/OcPG+9A4b8O3YT+HlXFSiOMIICfsnjOBoU7m\r
31  BsI8ARYRy8V3JeKc2iLOHuHGEC2F4iMT9MjJousS7yoBIy8naF5VfZBXDFSwB2P16NYa\r
32  7EjV2+vYCB5waRohtLqdIMutgYLrRWH/Lv7a9RnQRxMQ8NOgRbDmYedzTE3kPQfF7COy\r
33  d/xw==\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=HgPhSDwuoqgOYtgAd9a1oCRJA/XDKQZHrc/CHHR3Dk7WecRzcbjcYPpML1rA507xHU\r
40  fyvwPvnLfSt0DAycZdZAh3zVFH+SVJhpM6SqMyxdi1RH4yhCaPlArTCaoyRuOvZetS4U\r
41  mp6H3Tfpmqs3JzRAtRdC61o8rAEdeXxdaN+1E/9GzyZIW5c9BrZy57uUMYhAzpq0sz+d\r
42  0yGtOznCOf69Zzx1GguyZIoILZyLvukcOxCJBx+GuQ0Gc6+QkNaiLyMJfgujWXIuJ74T\r
43  ubQataYKZkC5e1FMLEBII9oUUliHfkbRqis9K6OlMagQDPBMcWPFzORwCmjFueG7H7b9\r
44  Y/9w==\r
45 X-Gm-Message-State:\r
46  AG10YOS05msXDZ6bJ03WkBsW4dbkbQbZ14cnT4mXtZzDqlcxZ6si0JWKUG8C0bXr/MMaSQ==\r
47 X-Received: by 10.28.218.78 with SMTP id r75mr44647558wmg.7.1454792881801;\r
48  Sat, 06 Feb 2016 13:08:01 -0800 (PST)\r
49 Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net.\r
50  [81.149.164.25])\r
51  by smtp.gmail.com with ESMTPSA id l7sm22000005wjx.14.2016.02.06.13.08.00\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 13:08:00 -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 53785319\r
57  for <notmuch@notmuchmail.org>; Sat, 6 Feb 2016 21:07:57 +0000 (UTC)\r
58 From: David Edmondson <dme@dme.org>\r
59 To: notmuch@notmuchmail.org\r
60 Subject: [PATCH v2 1/2] emacs: Add `notmuch-show-forward-open-messages'.\r
61 Date: Sat,  6 Feb 2016 21:07:56 +0000\r
62 Message-Id: <1454792877-7180-2-git-send-email-dme@dme.org>\r
63 X-Mailer: git-send-email 2.1.4\r
64 In-Reply-To: <1454792877-7180-1-git-send-email-dme@dme.org>\r
65 References: <1454792877-7180-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 21:08:06 -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