Reply all - issue
[notmuch-archives.git] / 40 / fd01621caf15119790cce7af79ee6b94927bff
1 Return-Path: <schnouki@schnouki.net>\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 3697E431FD0\r
6         for <notmuch@notmuchmail.org>; Wed,  9 Nov 2011 12:06:57 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.1\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1]\r
13         autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id N5Ur8tcvqtwo for <notmuch@notmuchmail.org>;\r
17         Wed,  9 Nov 2011 12:06:56 -0800 (PST)\r
18 Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222])\r
19         by olra.theworths.org (Postfix) with ESMTP id 5A56D431FB6\r
20         for <notmuch@notmuchmail.org>; Wed,  9 Nov 2011 12:06:56 -0800 (PST)\r
21 Received: from localhost.localdomain\r
22         (4va54-1-87-88-247-156.dsl.sta.abo.bbox.fr [87.88.247.156])\r
23         by ks3536.kimsufi.com (Postfix) with ESMTPSA id 4DBC96A0026;\r
24         Wed,  9 Nov 2011 21:06:55 +0100 (CET)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net;\r
26         s=key-schnouki; t=1320869215;\r
27         bh=iWXcLqcIVX/b4xYt46X5V09FIcXu4egn2h7O0X1qt6M=;\r
28         h=From:To:Subject:Date:Message-Id:In-Reply-To:References;\r
29         b=PZWtt6xuTYeJ+tz0JTVOR60uU5EHSyEJ9nS8xx3+eG3xNPEatS7AUVXzAu3+xTPMk\r
30         YMylxe1GkCpABZE3JfgzVP8PxCG8OWrJgDktiT4QG8WP+ViaKoWYjWql1eHqOdOLYP\r
31         liDIUj72jSP24xDFHJSA1lkLXdkZztwYvEePlh50=\r
32 From: Thomas Jost <schnouki@schnouki.net>\r
33 To: notmuch@notmuchmail.org\r
34 Subject: [PATCH v2] emacs: Let the user choose where to compose new mails\r
35 Date: Wed,  9 Nov 2011 21:06:09 +0100\r
36 Message-Id: <1320869169-32596-1-git-send-email-schnouki@schnouki.net>\r
37 X-Mailer: git-send-email 1.7.7.3\r
38 In-Reply-To: <87ipmt8700.fsf@schnouki.net>\r
39 References: <87ipmt8700.fsf@schnouki.net>\r
40 X-BeenThere: notmuch@notmuchmail.org\r
41 X-Mailman-Version: 2.1.13\r
42 Precedence: list\r
43 List-Id: "Use and development of the notmuch mail system."\r
44         <notmuch.notmuchmail.org>\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
46         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
48 List-Post: <mailto:notmuch@notmuchmail.org>\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
52 X-List-Received-Date: Wed, 09 Nov 2011 20:06:57 -0000\r
53 \r
54 ---\r
55  emacs/notmuch-mua.el |   40 ++++++++++++++++++++++++++++++++++++++--\r
56  1 files changed, 38 insertions(+), 2 deletions(-)\r
57 \r
58 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
59 index 8824b08..90834d6 100644\r
60 --- a/emacs/notmuch-mua.el\r
61 +++ b/emacs/notmuch-mua.el\r
62 @@ -31,6 +31,21 @@\r
63    :group 'notmuch\r
64    :type 'hook)\r
65  \r
66 +(defcustom notmuch-mua-compose-in 'current-window\r
67 +  "Where to create the mail buffer used to compose a new message.\r
68 +  Possible values are `current-window' (default), `new-window'\r
69 +  and `new-frame'. If set to `current-window', the mail buffer\r
70 +  will be displayed in the current window, so the old buffer will\r
71 +  be restored when the mail buffer is killed. If set to\r
72 +  `new-window' or `new-frame', the mail buffer will be displayed\r
73 +  in a new window/frame that will be destroyed when the buffer is\r
74 +  killed. You may want to customize `message-kill-buffer-on-exit'\r
75 +  accordingly."\r
76 +  :group 'notmuch\r
77 +  :type '(choice (const :tag "Compose in the current window" current-window)\r
78 +                (const :tag "Compose mail in a new window"  new-window)\r
79 +                (const :tag "Compose mail in a new frame"   new-frame)))\r
80 +\r
81  (defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-full\r
82    "Function used to generate a `User-Agent:' string. If this is\r
83  `nil' then no `User-Agent:' will be generated."\r
84 @@ -48,6 +63,23 @@ list."\r
85  \r
86  ;;\r
87  \r
88 +(defun notmuch-mua-get-switch-function ()\r
89 +  "Get a switch function according to `notmuch-mua-compose-in'."\r
90 +  (cond ((eq notmuch-mua-compose-in 'current-window)\r
91 +        'switch-to-buffer)\r
92 +       ((eq notmuch-mua-compose-in 'new-window)\r
93 +        'switch-to-buffer-other-window)\r
94 +       ((eq notmuch-mua-compose-in 'new-frame)\r
95 +        'switch-to-buffer-other-frame)\r
96 +       (t (error "Invalid value for `notmuch-mua-compose-in'"))))\r
97 +\r
98 +(defun notmuch-mua-maybe-set-window-dedicated ()\r
99 +  "Set the selected window as dedicated according to\r
100 +`notmuch-mua-compose-in'."\r
101 +  (when (or (eq notmuch-mua-compose-in 'new-frame)\r
102 +           (eq notmuch-mua-compose-in 'new-window))\r
103 +    (set-window-dedicated-p (selected-window) t)))\r
104 +\r
105  (defun notmuch-mua-user-agent-full ()\r
106    "Generate a `User-Agent:' string suitable for notmuch."\r
107    (concat (notmuch-mua-user-agent-notmuch)\r
108 @@ -99,7 +131,8 @@ list."\r
109         ((same-window-regexps '("\\*mail .*")))\r
110        (notmuch-mua-mail (mail-header 'to headers)\r
111                         (mail-header 'subject headers)\r
112 -                       (message-headers-to-generate headers t '(to subject))))\r
113 +                       (message-headers-to-generate headers t '(to subject))\r
114 +                       nil (notmuch-mua-get-switch-function)))\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 @@ -112,6 +145,7 @@ list."\r
119    (message-goto-body))\r
120  \r
121  (defun notmuch-mua-forward-message ()\r
122 +  (funcall (notmuch-mua-get-switch-function) (current-buffer))\r
123    (message-forward)\r
124  \r
125    (when notmuch-mua-user-agent-function\r
126 @@ -121,6 +155,7 @@ list."\r
127    (message-sort-headers)\r
128    (message-hide-headers)\r
129    (set-buffer-modified-p nil)\r
130 +  (notmuch-mua-maybe-set-window-dedicated)\r
131  \r
132    (message-goto-to))\r
133  \r
134 @@ -143,6 +178,7 @@ list."\r
135    (message-sort-headers)\r
136    (message-hide-headers)\r
137    (set-buffer-modified-p nil)\r
138 +  (notmuch-mua-maybe-set-window-dedicated)\r
139  \r
140    (message-goto-to))\r
141  \r
142 @@ -199,7 +235,7 @@ the From: address first."\r
143    (let ((other-headers\r
144          (when (or prompt-for-sender notmuch-always-prompt-for-sender)\r
145            (list (cons 'from (notmuch-mua-prompt-for-sender))))))\r
146 -    (notmuch-mua-mail nil nil other-headers)))\r
147 +    (notmuch-mua-mail nil nil other-headers nil (notmuch-mua-get-switch-function))))\r
148  \r
149  (defun notmuch-mua-new-forward-message (&optional prompt-for-sender)\r
150    "Invoke the notmuch message forwarding window.\r
151 -- \r
152 1.7.7.3\r
153 \r