Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 0e / 04e0b23bb0460164641a423c8371ba0280040c
1 Return-Path: <bremner@tesseract.cs.unb.ca>\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 5A2246DE17E9\r
6  for <notmuch@notmuchmail.org>; Tue,  4 Aug 2015 13:06:39 -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.146\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.146 tagged_above=-999 required=5 tests=[AWL=0.136, \r
12  T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id NW9EfkXjpW5A for <notmuch@notmuchmail.org>;\r
16  Tue,  4 Aug 2015 13:06:37 -0700 (PDT)\r
17 Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
18  by arlo.cworth.org (Postfix) with ESMTPS id DBB0F6DE1AA6\r
19  for <notmuch@notmuchmail.org>; Tue,  4 Aug 2015 13:06:36 -0700 (PDT)\r
20 Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
21  (envelope-from <bremner@tesseract.cs.unb.ca>)\r
22  id 1ZMiSJ-0002om-DA; Tue, 04 Aug 2015 20:04:59 +0000\r
23 Received: (nullmailer pid 11585 invoked by uid 1000); Tue, 04 Aug 2015\r
24  20:04:31 -0000\r
25 From: David Bremner <david@tethera.net>\r
26 To: David Bremner <david@tethera.net>, Mark Walters\r
27  <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
28 Subject: [PATCH 2/2] emacs: make modifications to message Fcc vars\r
29  buffer-local\r
30 Date: Tue,  4 Aug 2015 22:04:19 +0200\r
31 Message-Id: <1438718659-11522-2-git-send-email-david@tethera.net>\r
32 X-Mailer: git-send-email 2.1.4\r
33 In-Reply-To: <1438718659-11522-1-git-send-email-david@tethera.net>\r
34 References: <87fv4093sl.fsf@maritornes.cs.unb.ca>\r
35  <1438718659-11522-1-git-send-email-david@tethera.net>\r
36 X-BeenThere: notmuch@notmuchmail.org\r
37 X-Mailman-Version: 2.1.18\r
38 Precedence: list\r
39 List-Id: "Use and development of the notmuch mail system."\r
40  <notmuch.notmuchmail.org>\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
42  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
44 List-Post: <mailto:notmuch@notmuchmail.org>\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
47  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
48 X-List-Received-Date: Tue, 04 Aug 2015 20:06:39 -0000\r
49 \r
50 Previously we globally modified these variables, which tended to cause\r
51 problems for people using message-mode, but not notmuch-mua-mail, to\r
52 send mail.\r
53 \r
54 User visible changes:\r
55 \r
56 - calling notmuch-fcc-header-setup is no longer optional. OTOH, it\r
57   seems to do the right thing if notmuch-fcc-dirs is set to nil.\r
58 \r
59 - the Fcc header is visible during message composition\r
60 \r
61 - the name in the mode line is changed, and (sadface) no longer\r
62   matches the menu label.\r
63 \r
64 - Previously notmuch-mua-send-and-exit was never called.  Either we\r
65   misunderstood define-mail-user-agent, or it had a bug.  So there was\r
66   no difference if the user called message-send-and-exit directly. Now\r
67   there will be.\r
68 \r
69 - user bindings to C-c C-s and C-c C-s in message-mode-map are\r
70   overridden. The user can override them in notmuch-message-mode-map,\r
71   but then they're on their own for Fcc handling.\r
72 ---\r
73  emacs/notmuch-maildir-fcc.el | 23 +++++++++--------------\r
74  emacs/notmuch-mua.el         | 15 +++++++++++++--\r
75  test/test-lib.sh             |  4 ++--\r
76  3 files changed, 24 insertions(+), 18 deletions(-)\r
77 \r
78 diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el\r
79 index 07eedba..c2f2f4c 100644\r
80 --- a/emacs/notmuch-maildir-fcc.el\r
81 +++ b/emacs/notmuch-maildir-fcc.el\r
82 @@ -59,23 +59,19 @@ yet when sending a mail."\r
83   :require 'notmuch-fcc-initialization\r
84   :group 'notmuch-send)\r
85  \r
86 -(defun notmuch-fcc-initialization ()\r
87 -  "If notmuch-fcc-directories is set,\r
88 -   hook them into the message-fcc-handler-function"\r
89 -    ;; Set up the message-fcc-handler to move mails to the maildir in Fcc\r
90 -    ;; The parameter is set to mark messages as "seen"\r
91 -    (setq message-fcc-handler-function\r
92 -          (lambda (destdir)\r
93 -           (notmuch-maildir-fcc-write-buffer-to-maildir destdir t)))\r
94 -    ;; add a hook to actually insert the Fcc header when sending\r
95 -    (add-hook 'message-header-setup-hook 'notmuch-fcc-header-setup))\r
96 +(defun notmuch-fcc-handler (destdir)\r
97 +  "Write buffer to `destdir', marking it as sent\r
98 +\r
99 +Intended to be dynamically bound to `message-fcc-handler-function'"\r
100 +    (notmuch-maildir-fcc-write-buffer-to-maildir destdir t))\r
101  \r
102  (defun notmuch-fcc-header-setup ()\r
103    "Add an Fcc header to the current message buffer.\r
104  \r
105 -Can be added to `message-send-hook' and will set the Fcc header\r
106 -based on the values of `notmuch-fcc-dirs'. An existing Fcc header\r
107 -will NOT be removed or replaced."\r
108 +Sets the Fcc header based on the values of `notmuch-fcc-dirs'.\r
109 +\r
110 +Originally intended to be use a hook function, but now called directly\r
111 +by notmuch-mua-mail"\r
112  \r
113    (let ((subdir\r
114          (cond\r
115 @@ -213,6 +209,5 @@ return t if successful, and nil otherwise."\r
116           (delete-file (concat destdir "/tmp/" msg-id))))\r
117        t)))\r
118  \r
119 -(notmuch-fcc-initialization)\r
120  (provide 'notmuch-maildir-fcc)\r
121  \r
122 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
123 index 1018321..803459a 100644\r
124 --- a/emacs/notmuch-mua.el\r
125 +++ b/emacs/notmuch-mua.el\r
126 @@ -268,9 +268,13 @@ Note that these functions use `mail-citation-hook' if that is non-nil."\r
127    (message-goto-body)\r
128    (set-buffer-modified-p nil))\r
129  \r
130 -(define-derived-mode notmuch-message-mode message-mode "Notmuch Message"\r
131 +(define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]"\r
132    "Notmuch message composition mode. Mostly like `message-mode'")\r
133  \r
134 +(define-key notmuch-message-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)\r
135 +(define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send)\r
136 +\r
137 +\r
138  (defun notmuch-mua-mail (&optional to subject other-headers &rest other-args)\r
139    "Invoke the notmuch mail composition window.\r
140  \r
141 @@ -288,6 +292,7 @@ OTHER-ARGS are passed through to `message-mail'."\r
142  \r
143    (apply #'message-mail to subject other-headers other-args)\r
144    (notmuch-message-mode)\r
145 +  (notmuch-fcc-header-setup)\r
146    (message-sort-headers)\r
147    (message-hide-headers)\r
148    (set-buffer-modified-p nil)\r
149 @@ -401,7 +406,13 @@ will be addressed to all recipients of the source message."\r
150  \r
151  (defun notmuch-mua-send-and-exit (&optional arg)\r
152    (interactive "P")\r
153 -  (message-send-and-exit arg))\r
154 +  (let ((message-fcc-handler-function #'notmuch-fcc-handler))\r
155 +    (message-send-and-exit arg)))\r
156 +\r
157 +(defun notmuch-mua-send (&optional arg)\r
158 +  (interactive "P")\r
159 +  (let ((message-fcc-handler-function #'notmuch-fcc-handler))\r
160 +    (message-send arg)))\r
161  \r
162  (defun notmuch-mua-kill-buffer ()\r
163    (interactive)\r
164 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
165 index db3b6aa..eeb5487 100644\r
166 --- a/test/test-lib.sh\r
167 +++ b/test/test-lib.sh\r
168 @@ -487,7 +487,7 @@ emacs_deliver_message ()\r
169            (message-goto-body)\r
170            (insert \"${body}\")\r
171            $@\r
172 -          (message-send-and-exit))"\r
173 +          (notmuch-mua-send-and-exit))"\r
174  \r
175      # In case message was sent properly, client waits for confirmation\r
176      # before exiting and resuming control here; therefore making sure\r
177 @@ -522,7 +522,7 @@ emacs_fcc_message ()\r
178            (message-goto-body)\r
179            (insert \"${body}\")\r
180            $@\r
181 -          (message-send-and-exit))" || return 1\r
182 +          (notmuch-mua-send-and-exit))" || return 1\r
183      notmuch new >/dev/null\r
184  }\r
185  \r
186 -- \r
187 2.1.4\r
188 \r