[PATCH v6] emacs: Let the user choose where to compose new mails
authorThomas Jost <schnouki@schnouki.net>
Fri, 4 May 2012 10:37:56 +0000 (12:37 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:53 +0000 (09:46 -0800)
b2/5a2a1de47f19629be0224f0dab3a57bc5cf8d1 [new file with mode: 0644]

diff --git a/b2/5a2a1de47f19629be0224f0dab3a57bc5cf8d1 b/b2/5a2a1de47f19629be0224f0dab3a57bc5cf8d1
new file mode 100644 (file)
index 0000000..f831b5c
--- /dev/null
@@ -0,0 +1,179 @@
+Return-Path: <schnouki@schnouki.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 5FDF7431FB6\r
+       for <notmuch@notmuchmail.org>; Fri,  4 May 2012 03:38:24 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.1\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id SpwhaGDuAAsP for <notmuch@notmuchmail.org>;\r
+       Fri,  4 May 2012 03:38:23 -0700 (PDT)\r
+Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222])\r
+       by olra.theworths.org (Postfix) with ESMTP id 3AEF6431FAE\r
+       for <notmuch@notmuchmail.org>; Fri,  4 May 2012 03:38:23 -0700 (PDT)\r
+Received: from thor.loria.fr (thor.loria.fr [152.81.12.250])\r
+       by ks3536.kimsufi.com (Postfix) with ESMTPSA id 84D1B6C000B;\r
+       Fri,  4 May 2012 12:38:24 +0200 (CEST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net;\r
+       s=key-schnouki; t=1336127904;\r
+       bh=k2vQdUdNF4pEiT7h+r9d6yZAP+jpk2k0rDmxIljJvHk=;\r
+       h=From:To:Cc:Subject:Date:In-Reply-To:References;\r
+       b=S1BNjNpD9s47cdXZcVZevsbl1xoEEtJST9QT++1sJ+dRQar2fFzkuLSlDnqtWYp7e\r
+       TEpDO9/DG1txHqC3iCvfg+WMdo4TsrZk6b9jz04T4yU6FvFxWz8t6W3XLgqpTkIJCu\r
+       LzfHHQmcJBoykZLKJ1Lz6zUOo3HH8pm5AgLTr87Q=\r
+From: Thomas Jost <schnouki@schnouki.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v6] emacs: Let the user choose where to compose new mails\r
+Date: Fri,  4 May 2012 12:37:56 +0200\r
+Message-Id: <1336127876-6765-1-git-send-email-schnouki@schnouki.net>\r
+X-Mailer: git-send-email 1.7.10.1\r
+In-Reply-To: <87k40yfj2z.fsf@zancas.localnet>\r
+References: <87k40yfj2z.fsf@zancas.localnet>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 04 May 2012 10:38:24 -0000\r
+\r
+Introduce a new defcustom notmuch-mua-compose-in that allows users to\r
+specify where new mails are composed, either in the current window or\r
+in a new window or frame.\r
+\r
+Signed-off-by: Jameson Rollins <jrollins@finestructure.net>\r
+---\r
+Hi David et al.,\r
+\r
+Here it is again, with a warning in the customize message that only\r
+appears in Emacs 23. The indentation is a little bit of a mess but\r
+that's needed for the docstring to look good :)\r
+\r
+(If you want I can remove the test and also display the Emacs 23\r
+warning in Emacs 24.)\r
+\r
+Does it look good to you? I'm not comfortable with writing docs in\r
+English, so feel free to rephrase it if needed.\r
+\r
+I also moved notmuch-mua-compose-in to the 'notmuch-send group, just\r
+as other notmuch-mua-* variables.\r
+\r
+Regards,\r
+Thomas\r
+\r
+ emacs/notmuch-mua.el |   45 +++++++++++++++++++++++++++++++++++++++++++--\r
+ 1 file changed, 43 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 87bd88d..641dae7 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -36,6 +36,26 @@\r
+   :group 'notmuch-send\r
+   :group 'notmuch-hooks)\r
+\r
++(defcustom notmuch-mua-compose-in 'current-window\r
++  (concat\r
++   "Where to create the mail buffer used to compose a new message.\r
++Possible values are `current-window' (default), `new-window' and\r
++`new-frame'. If set to `current-window', the mail buffer will be\r
++displayed in the current window, so the old buffer will be\r
++restored when the mail buffer is killed. If set to `new-window'\r
++or `new-frame', the mail buffer will be displayed in a new\r
++window/frame that will be destroyed when the buffer is killed.\r
++You may want to customize `message-kill-buffer-on-exit'\r
++accordingly."\r
++   (when (< emacs-major-version 24)\r
++           " Due to a known bug in Emacs 23, you should not set\r
++this to `new-window' if `message-kill-buffer-on-exit' is\r
++disabled: this would result in an incorrect behavior."))\r
++  :group 'notmuch-send\r
++  :type '(choice (const :tag "Compose in the current window" current-window)\r
++               (const :tag "Compose mail in a new window"  new-window)\r
++               (const :tag "Compose mail in a new frame"   new-frame)))\r
++\r
+ (defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-full\r
+   "Function used to generate a `User-Agent:' string. If this is\r
+ `nil' then no `User-Agent:' will be generated."\r
+@@ -55,6 +75,23 @@ list."\r
+\r
+ ;;\r
+\r
++(defun notmuch-mua-get-switch-function ()\r
++  "Get a switch function according to `notmuch-mua-compose-in'."\r
++  (cond ((eq notmuch-mua-compose-in 'current-window)\r
++       'switch-to-buffer)\r
++      ((eq notmuch-mua-compose-in 'new-window)\r
++       'switch-to-buffer-other-window)\r
++      ((eq notmuch-mua-compose-in 'new-frame)\r
++       'switch-to-buffer-other-frame)\r
++      (t (error "Invalid value for `notmuch-mua-compose-in'"))))\r
++\r
++(defun notmuch-mua-maybe-set-window-dedicated ()\r
++  "Set the selected window as dedicated according to\r
++`notmuch-mua-compose-in'."\r
++  (when (or (eq notmuch-mua-compose-in 'new-frame)\r
++          (eq notmuch-mua-compose-in 'new-window))\r
++    (set-window-dedicated-p (selected-window) t)))\r
++\r
+ (defun notmuch-mua-user-agent-full ()\r
+   "Generate a `User-Agent:' string suitable for notmuch."\r
+   (concat (notmuch-mua-user-agent-notmuch)\r
+@@ -148,7 +185,8 @@ list."\r
+                    collect pair)))\r
+         (notmuch-mua-mail (plist-get reply-headers :To)\r
+                           (plist-get reply-headers :Subject)\r
+-                          (notmuch-headers-plist-to-alist reply-headers))))\r
++                          (notmuch-headers-plist-to-alist reply-headers)\r
++                          nil (notmuch-mua-get-switch-function))))\r
+\r
+       ;; Insert the message body - but put it in front of the signature\r
+       ;; if one is present\r
+@@ -186,6 +224,7 @@ list."\r
+   (set-buffer-modified-p nil))\r
+\r
+ (defun notmuch-mua-forward-message ()\r
++  (funcall (notmuch-mua-get-switch-function) (current-buffer))\r
+   (message-forward)\r
+\r
+   (when notmuch-mua-user-agent-function\r
+@@ -195,6 +234,7 @@ list."\r
+   (message-sort-headers)\r
+   (message-hide-headers)\r
+   (set-buffer-modified-p nil)\r
++  (notmuch-mua-maybe-set-window-dedicated)\r
+\r
+   (message-goto-to))\r
+\r
+@@ -217,6 +257,7 @@ OTHER-ARGS are passed through to `message-mail'."\r
+   (message-sort-headers)\r
+   (message-hide-headers)\r
+   (set-buffer-modified-p nil)\r
++  (notmuch-mua-maybe-set-window-dedicated)\r
+\r
+   (message-goto-to))\r
+\r
+@@ -273,7 +314,7 @@ the From: address first."\r
+   (let ((other-headers\r
+        (when (or prompt-for-sender notmuch-always-prompt-for-sender)\r
+          (list (cons 'From (notmuch-mua-prompt-for-sender))))))\r
+-    (notmuch-mua-mail nil nil other-headers)))\r
++    (notmuch-mua-mail nil nil other-headers nil (notmuch-mua-get-switch-function))))\r
+\r
+ (defun notmuch-mua-new-forward-message (&optional prompt-for-sender)\r
+   "Invoke the notmuch message forwarding window.\r
+--\r
+1.7.10.1\r