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 92171429E25
\r
6 for <notmuch@notmuchmail.org>; Tue, 13 Dec 2011 09:32:31 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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
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 UEyR5jUf4ZRr for <notmuch@notmuchmail.org>;
\r
17 Tue, 13 Dec 2011 09:32:30 -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 1209B429E26
\r
20 for <notmuch@notmuchmail.org>; Tue, 13 Dec 2011 09:32:30 -0800 (PST)
\r
21 Received: from thor.loria.fr (thor.loria.fr [152.81.12.250])
\r
22 by ks3536.kimsufi.com (Postfix) with ESMTPSA id 6749D6A0028;
\r
23 Tue, 13 Dec 2011 18:32:29 +0100 (CET)
\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net;
\r
25 s=key-schnouki; t=1323797549;
\r
26 bh=/mU8q2lhptXpKRUhKjUrVmoxFF1hX6Jw0wR4NjZFo8I=;
\r
27 h=From:To:Subject:Date:Message-Id:In-Reply-To:References;
\r
28 b=OUkRsa6Y2+kFsa0LoffWalLcpGRrMd+IomIdQbUxWAfLLmydYBFSttgHjwijRcB5q
\r
29 00cfY8+fPX/JV5r+QvYK2S/0IBGxR2v0wt287EItVfDAnDNdi9FRSJkhpNNZ+wZfGc
\r
30 m4URxAt4oea04GlYYfr+Ig7IVYebKZEYqXeCa5eY=
\r
31 From: Thomas Jost <schnouki@schnouki.net>
\r
32 To: notmuch@notmuchmail.org
\r
33 Subject: [PATCH v3 1/4] emacs: Let the user choose where to compose new mails
\r
34 Date: Tue, 13 Dec 2011 18:32:09 +0100
\r
35 Message-Id: <1323797532-597-2-git-send-email-schnouki@schnouki.net>
\r
36 X-Mailer: git-send-email 1.7.8
\r
37 In-Reply-To: <1323797532-597-1-git-send-email-schnouki@schnouki.net>
\r
38 References: <87d3cx2t38.fsf@rocinante.cs.unb.ca>
\r
39 <1323797532-597-1-git-send-email-schnouki@schnouki.net>
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\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: Tue, 13 Dec 2011 17:32:31 -0000
\r
54 Reusing the current window to compose a new mail may be troublesome for the
\r
55 user. This patch introduces a new customizable variable, notmuch-mua-compose-in,
\r
56 which lets the user choose where to create the mail buffer: in the current
\r
57 window (current and default behaviour), in a new window, or in a new frame.
\r
59 emacs/notmuch-mua.el | 40 ++++++++++++++++++++++++++++++++++++++--
\r
60 1 files changed, 38 insertions(+), 2 deletions(-)
\r
62 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
\r
63 index 8824b08..90834d6 100644
\r
64 --- a/emacs/notmuch-mua.el
\r
65 +++ b/emacs/notmuch-mua.el
\r
70 +(defcustom notmuch-mua-compose-in 'current-window
\r
71 + "Where to create the mail buffer used to compose a new message.
\r
72 + Possible values are `current-window' (default), `new-window'
\r
73 + and `new-frame'. If set to `current-window', the mail buffer
\r
74 + will be displayed in the current window, so the old buffer will
\r
75 + be restored when the mail buffer is killed. If set to
\r
76 + `new-window' or `new-frame', the mail buffer will be displayed
\r
77 + in a new window/frame that will be destroyed when the buffer is
\r
78 + killed. You may want to customize `message-kill-buffer-on-exit'
\r
81 + :type '(choice (const :tag "Compose in the current window" current-window)
\r
82 + (const :tag "Compose mail in a new window" new-window)
\r
83 + (const :tag "Compose mail in a new frame" new-frame)))
\r
85 (defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-full
\r
86 "Function used to generate a `User-Agent:' string. If this is
\r
87 `nil' then no `User-Agent:' will be generated."
\r
88 @@ -48,6 +63,23 @@ list."
\r
92 +(defun notmuch-mua-get-switch-function ()
\r
93 + "Get a switch function according to `notmuch-mua-compose-in'."
\r
94 + (cond ((eq notmuch-mua-compose-in 'current-window)
\r
95 + 'switch-to-buffer)
\r
96 + ((eq notmuch-mua-compose-in 'new-window)
\r
97 + 'switch-to-buffer-other-window)
\r
98 + ((eq notmuch-mua-compose-in 'new-frame)
\r
99 + 'switch-to-buffer-other-frame)
\r
100 + (t (error "Invalid value for `notmuch-mua-compose-in'"))))
\r
102 +(defun notmuch-mua-maybe-set-window-dedicated ()
\r
103 + "Set the selected window as dedicated according to
\r
104 +`notmuch-mua-compose-in'."
\r
105 + (when (or (eq notmuch-mua-compose-in 'new-frame)
\r
106 + (eq notmuch-mua-compose-in 'new-window))
\r
107 + (set-window-dedicated-p (selected-window) t)))
\r
109 (defun notmuch-mua-user-agent-full ()
\r
110 "Generate a `User-Agent:' string suitable for notmuch."
\r
111 (concat (notmuch-mua-user-agent-notmuch)
\r
112 @@ -99,7 +131,8 @@ list."
\r
113 ((same-window-regexps '("\\*mail .*")))
\r
114 (notmuch-mua-mail (mail-header 'to headers)
\r
115 (mail-header 'subject headers)
\r
116 - (message-headers-to-generate headers t '(to subject))))
\r
117 + (message-headers-to-generate headers t '(to subject))
\r
118 + nil (notmuch-mua-get-switch-function)))
\r
119 ;; insert the message body - but put it in front of the signature
\r
120 ;; if one is present
\r
121 (goto-char (point-max))
\r
122 @@ -112,6 +145,7 @@ list."
\r
123 (message-goto-body))
\r
125 (defun notmuch-mua-forward-message ()
\r
126 + (funcall (notmuch-mua-get-switch-function) (current-buffer))
\r
129 (when notmuch-mua-user-agent-function
\r
130 @@ -121,6 +155,7 @@ list."
\r
131 (message-sort-headers)
\r
132 (message-hide-headers)
\r
133 (set-buffer-modified-p nil)
\r
134 + (notmuch-mua-maybe-set-window-dedicated)
\r
138 @@ -143,6 +178,7 @@ list."
\r
139 (message-sort-headers)
\r
140 (message-hide-headers)
\r
141 (set-buffer-modified-p nil)
\r
142 + (notmuch-mua-maybe-set-window-dedicated)
\r
146 @@ -199,7 +235,7 @@ the From: address first."
\r
147 (let ((other-headers
\r
148 (when (or prompt-for-sender notmuch-always-prompt-for-sender)
\r
149 (list (cons 'from (notmuch-mua-prompt-for-sender))))))
\r
150 - (notmuch-mua-mail nil nil other-headers)))
\r
151 + (notmuch-mua-mail nil nil other-headers nil (notmuch-mua-get-switch-function))))
\r
153 (defun notmuch-mua-new-forward-message (&optional prompt-for-sender)
\r
154 "Invoke the notmuch message forwarding window.
\r