Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / b2 / 5a2a1de47f19629be0224f0dab3a57bc5cf8d1
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 5FDF7431FB6\r
6         for <notmuch@notmuchmail.org>; Fri,  4 May 2012 03:38:24 -0700 (PDT)\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 SpwhaGDuAAsP for <notmuch@notmuchmail.org>;\r
17         Fri,  4 May 2012 03:38:23 -0700 (PDT)\r
18 Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222])\r
19         by olra.theworths.org (Postfix) with ESMTP id 3AEF6431FAE\r
20         for <notmuch@notmuchmail.org>; Fri,  4 May 2012 03:38:23 -0700 (PDT)\r
21 Received: from thor.loria.fr (thor.loria.fr [152.81.12.250])\r
22         by ks3536.kimsufi.com (Postfix) with ESMTPSA id 84D1B6C000B;\r
23         Fri,  4 May 2012 12:38:24 +0200 (CEST)\r
24 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net;\r
25         s=key-schnouki; t=1336127904;\r
26         bh=k2vQdUdNF4pEiT7h+r9d6yZAP+jpk2k0rDmxIljJvHk=;\r
27         h=From:To:Cc:Subject:Date:In-Reply-To:References;\r
28         b=S1BNjNpD9s47cdXZcVZevsbl1xoEEtJST9QT++1sJ+dRQar2fFzkuLSlDnqtWYp7e\r
29         TEpDO9/DG1txHqC3iCvfg+WMdo4TsrZk6b9jz04T4yU6FvFxWz8t6W3XLgqpTkIJCu\r
30         LzfHHQmcJBoykZLKJ1Lz6zUOo3HH8pm5AgLTr87Q=\r
31 From: Thomas Jost <schnouki@schnouki.net>\r
32 To: notmuch@notmuchmail.org\r
33 Subject: [PATCH v6] emacs: Let the user choose where to compose new mails\r
34 Date: Fri,  4 May 2012 12:37:56 +0200\r
35 Message-Id: <1336127876-6765-1-git-send-email-schnouki@schnouki.net>\r
36 X-Mailer: git-send-email 1.7.10.1\r
37 In-Reply-To: <87k40yfj2z.fsf@zancas.localnet>\r
38 References: <87k40yfj2z.fsf@zancas.localnet>\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Fri, 04 May 2012 10:38:24 -0000\r
52 \r
53 Introduce a new defcustom notmuch-mua-compose-in that allows users to\r
54 specify where new mails are composed, either in the current window or\r
55 in a new window or frame.\r
56 \r
57 Signed-off-by: Jameson Rollins <jrollins@finestructure.net>\r
58 ---\r
59 Hi David et al.,\r
60 \r
61 Here it is again, with a warning in the customize message that only\r
62 appears in Emacs 23. The indentation is a little bit of a mess but\r
63 that's needed for the docstring to look good :)\r
64 \r
65 (If you want I can remove the test and also display the Emacs 23\r
66 warning in Emacs 24.)\r
67 \r
68 Does it look good to you? I'm not comfortable with writing docs in\r
69 English, so feel free to rephrase it if needed.\r
70 \r
71 I also moved notmuch-mua-compose-in to the 'notmuch-send group, just\r
72 as other notmuch-mua-* variables.\r
73 \r
74 Regards,\r
75 Thomas\r
76 \r
77  emacs/notmuch-mua.el |   45 +++++++++++++++++++++++++++++++++++++++++++--\r
78  1 file changed, 43 insertions(+), 2 deletions(-)\r
79 \r
80 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
81 index 87bd88d..641dae7 100644\r
82 --- a/emacs/notmuch-mua.el\r
83 +++ b/emacs/notmuch-mua.el\r
84 @@ -36,6 +36,26 @@\r
85    :group 'notmuch-send\r
86    :group 'notmuch-hooks)\r
87 \r
88 +(defcustom notmuch-mua-compose-in 'current-window\r
89 +  (concat\r
90 +   "Where to create the mail buffer used to compose a new message.\r
91 +Possible values are `current-window' (default), `new-window' and\r
92 +`new-frame'. If set to `current-window', the mail buffer will be\r
93 +displayed in the current window, so the old buffer will be\r
94 +restored when the mail buffer is killed. If set to `new-window'\r
95 +or `new-frame', the mail buffer will be displayed in a new\r
96 +window/frame that will be destroyed when the buffer is killed.\r
97 +You may want to customize `message-kill-buffer-on-exit'\r
98 +accordingly."\r
99 +   (when (< emacs-major-version 24)\r
100 +           " Due to a known bug in Emacs 23, you should not set\r
101 +this to `new-window' if `message-kill-buffer-on-exit' is\r
102 +disabled: this would result in an incorrect behavior."))\r
103 +  :group 'notmuch-send\r
104 +  :type '(choice (const :tag "Compose in the current window" current-window)\r
105 +                (const :tag "Compose mail in a new window"  new-window)\r
106 +                (const :tag "Compose mail in a new frame"   new-frame)))\r
107 +\r
108  (defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-full\r
109    "Function used to generate a `User-Agent:' string. If this is\r
110  `nil' then no `User-Agent:' will be generated."\r
111 @@ -55,6 +75,23 @@ list."\r
112 \r
113  ;;\r
114 \r
115 +(defun notmuch-mua-get-switch-function ()\r
116 +  "Get a switch function according to `notmuch-mua-compose-in'."\r
117 +  (cond ((eq notmuch-mua-compose-in 'current-window)\r
118 +        'switch-to-buffer)\r
119 +       ((eq notmuch-mua-compose-in 'new-window)\r
120 +        'switch-to-buffer-other-window)\r
121 +       ((eq notmuch-mua-compose-in 'new-frame)\r
122 +        'switch-to-buffer-other-frame)\r
123 +       (t (error "Invalid value for `notmuch-mua-compose-in'"))))\r
124 +\r
125 +(defun notmuch-mua-maybe-set-window-dedicated ()\r
126 +  "Set the selected window as dedicated according to\r
127 +`notmuch-mua-compose-in'."\r
128 +  (when (or (eq notmuch-mua-compose-in 'new-frame)\r
129 +           (eq notmuch-mua-compose-in 'new-window))\r
130 +    (set-window-dedicated-p (selected-window) t)))\r
131 +\r
132  (defun notmuch-mua-user-agent-full ()\r
133    "Generate a `User-Agent:' string suitable for notmuch."\r
134    (concat (notmuch-mua-user-agent-notmuch)\r
135 @@ -148,7 +185,8 @@ list."\r
136                      collect pair)))\r
137           (notmuch-mua-mail (plist-get reply-headers :To)\r
138                             (plist-get reply-headers :Subject)\r
139 -                           (notmuch-headers-plist-to-alist reply-headers))))\r
140 +                           (notmuch-headers-plist-to-alist reply-headers)\r
141 +                           nil (notmuch-mua-get-switch-function))))\r
142 \r
143        ;; Insert the message body - but put it in front of the signature\r
144        ;; if one is present\r
145 @@ -186,6 +224,7 @@ list."\r
146    (set-buffer-modified-p nil))\r
147 \r
148  (defun notmuch-mua-forward-message ()\r
149 +  (funcall (notmuch-mua-get-switch-function) (current-buffer))\r
150    (message-forward)\r
151 \r
152    (when notmuch-mua-user-agent-function\r
153 @@ -195,6 +234,7 @@ list."\r
154    (message-sort-headers)\r
155    (message-hide-headers)\r
156    (set-buffer-modified-p nil)\r
157 +  (notmuch-mua-maybe-set-window-dedicated)\r
158 \r
159    (message-goto-to))\r
160 \r
161 @@ -217,6 +257,7 @@ OTHER-ARGS are passed through to `message-mail'."\r
162    (message-sort-headers)\r
163    (message-hide-headers)\r
164    (set-buffer-modified-p nil)\r
165 +  (notmuch-mua-maybe-set-window-dedicated)\r
166 \r
167    (message-goto-to))\r
168 \r
169 @@ -273,7 +314,7 @@ the From: address first."\r
170    (let ((other-headers\r
171          (when (or prompt-for-sender notmuch-always-prompt-for-sender)\r
172            (list (cons 'From (notmuch-mua-prompt-for-sender))))))\r
173 -    (notmuch-mua-mail nil nil other-headers)))\r
174 +    (notmuch-mua-mail nil nil other-headers nil (notmuch-mua-get-switch-function))))\r
175 \r
176  (defun notmuch-mua-new-forward-message (&optional prompt-for-sender)\r
177    "Invoke the notmuch message forwarding window.\r
178 --\r
179 1.7.10.1\r