Re: [PATCH] emacs: Let the user choose where to compose new mails
authorAustin Clements <amdragon@mit.edu>
Sat, 5 Nov 2011 03:51:55 +0000 (23:51 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:39:59 +0000 (09:39 -0800)
03/3cc73bd5640ba25d1f5e3b0500ffb4f2af29d3 [new file with mode: 0644]

diff --git a/03/3cc73bd5640ba25d1f5e3b0500ffb4f2af29d3 b/03/3cc73bd5640ba25d1f5e3b0500ffb4f2af29d3
new file mode 100644 (file)
index 0000000..52ab6b7
--- /dev/null
@@ -0,0 +1,204 @@
+Return-Path: <amdragon@gmail.com>\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 0FD80429E26\r
+       for <notmuch@notmuchmail.org>; Fri,  4 Nov 2011 20:51:58 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.699\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] 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 3ft+ooicgOp3 for <notmuch@notmuchmail.org>;\r
+       Fri,  4 Nov 2011 20:51:56 -0700 (PDT)\r
+Received: from mail-iy0-f181.google.com (mail-iy0-f181.google.com\r
+       [209.85.210.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 5C960431FB6\r
+       for <notmuch@notmuchmail.org>; Fri,  4 Nov 2011 20:51:56 -0700 (PDT)\r
+Received: by iahk25 with SMTP id k25so4167775iah.26\r
+       for <notmuch@notmuchmail.org>; Fri, 04 Nov 2011 20:51:56 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=mime-version:sender:in-reply-to:references:date\r
+       :x-google-sender-auth:message-id:subject:from:to:cc:content-type\r
+       :content-transfer-encoding;\r
+       bh=2ZaYleD2PSTGzxy0/SJPE+Rlkgw4FagwkUu0An/xuKI=;\r
+       b=dibRBpgetfymXA/FunEkjCDDyQy22mrUFFyrT6OA+baHg20m11lgLsqP/UbdoMhZYK\r
+       VJZ19xF2a3HyRgMZcUn0JRuPRiRicRIu8xfJEZ+rpBz5Zo2I4SNHO2QZzsU1Ml3fifEa\r
+       GNID8XEQBuEzPVnyLMCdVBGfPtIibQvQ40joE=\r
+MIME-Version: 1.0\r
+Received: by 10.42.144.65 with SMTP id a1mr20777348icv.46.1320465115888; Fri,\r
+       04 Nov 2011 20:51:55 -0700 (PDT)\r
+Sender: amdragon@gmail.com\r
+Received: by 10.143.166.17 with HTTP; Fri, 4 Nov 2011 20:51:55 -0700 (PDT)\r
+In-Reply-To: <1319528464-22654-1-git-send-email-schnouki@schnouki.net>\r
+References: <87pqhlh64c.fsf@thor.loria.fr>\r
+       <1319528464-22654-1-git-send-email-schnouki@schnouki.net>\r
+Date: Fri, 4 Nov 2011 23:51:55 -0400\r
+X-Google-Sender-Auth: 7_SnhWNZcZRm_eWwPFtn2uOs_Rk\r
+Message-ID:\r
+ <CAH-f9WvuSFJJC+e0JRFwKD8xYtyncNYZreCXxxMDeSahpWAuRw@mail.gmail.com>\r
+Subject: Re: [PATCH] emacs: Let the user choose where to compose new mails\r
+From: Austin Clements <amdragon@mit.edu>\r
+To: Thomas Jost <schnouki@schnouki.net>\r
+Content-Type: text/plain; charset=ISO-8859-1\r
+Content-Transfer-Encoding: quoted-printable\r
+Cc: notmuch@notmuchmail.org\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: Sat, 05 Nov 2011 03:51:58 -0000\r
+\r
+This seems like a good option to have, but your approach seems\r
+unnecessarily complicated. I'm always wary of defcustom's :set because\r
+it means you can't just setq the variable, which defeats the\r
+underlying beauty of the customize system.=A0 You could eliminate the\r
+other two variables and compute them on the fly, or, if you really\r
+feel they may need to be controlled independently, make the custom\r
+variable a pair or alist (which you can hide behind a few const\r
+choices).  Alternatively, it seems like the variable could instead\r
+take a single function (basically what notmuch-mua-switch-function is\r
+now) and you could provide two new functions that simply combine\r
+switch-to-buffer-other-x and set-window-dedicated-p.\r
+\r
+On Oct 25, 2011 3:41 AM, "Thomas Jost" <schnouki@schnouki.net> wrote:\r
+>\r
+> ---\r
+> =A0emacs/notmuch-mua.el | =A0 37 +++++++++++++++++++++++++++++++++++--\r
+> =A01 files changed, 35 insertions(+), 2 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+> index 8824b08..ebc922f 100644\r
+> --- a/emacs/notmuch-mua.el\r
+> +++ b/emacs/notmuch-mua.el\r
+> @@ -31,6 +31,34 @@\r
+> =A0 :group 'notmuch\r
+> =A0 :type 'hook)\r
+>\r
+> +(defvar notmuch-mua-switch-function nil\r
+> + =A0"Function used to switch and display the mail buffer. This is\r
+> + =A0normally set by `notmuch-mua-compose-in'.")\r
+> +(defvar notmuch-mua-dedicated-flag nil\r
+> + =A0"Flag to pass to `set-window-dedicated-p' in the mail buffer.\r
+> + =A0This is normally set by `notmuch-mua-compose-in'.")\r
+> +(defcustom notmuch-mua-compose-in 'current-window\r
+> + =A0"Where to create the mail buffer used to compose a new message.\r
+> + =A0Possible values are `current-window' (default), `new-window'\r
+> + =A0and `new-frame'. If set to `new-window' or `new-frame', the\r
+> + =A0mail buffer will be displayer in a new window/frame that will\r
+\r
+s/displayer/displayed/\r
+\r
+> + =A0be destroyed when the buffer is killed. You may want to\r
+> + =A0customize `message-kill-buffer-on-exit' accordingly."\r
+\r
+You should also describe 'current-window' in the defcustom docstring.\r
+(Currently you describe the effect of the other two, but not\r
+current-window.)\r
+\r
+> + =A0:group 'notmuch\r
+> + =A0:type 'symbol\r
+> + =A0:set (lambda (sym val)\r
+> + =A0 =A0 =A0 =A0(cond ((eq val 'current-window)\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq notmuch-mua-switch-function nil\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 notmuch-mua-dedicated-flag nil)=\r
+)\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0((eq val 'new-window)\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq notmuch-mua-switch-function 'switch-t=\r
+o-buffer-other-window\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 notmuch-mua-dedicated-flag 1))\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0((eq val 'new-frame)\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 (setq notmuch-mua-switch-function 'switch-t=\r
+o-buffer-other-frame\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 notmuch-mua-dedicated-flag 1))\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0(t (error (concat "Bad value for notmuch-mua=\r
+-compose-in: "\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(symbol-=\r
+value val)))))))\r
+> +\r
+\r
+The defcustom would be more user-friendly if it gave a choice between\r
+const values, rather than requiring the user to enter a symbol value\r
+(and then possibly rejecting it on validation).  Something like\r
+  :type '(choice (const :tag "Compose in the current window" current-window=\r
+)\r
+                 (const :tag "Compose mail in a new window"  new-window)\r
+                 (const :tag "Compose mail in a new frame"   new-frame))\r
+\r
+> =A0(defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-ful=\r
+l\r
+> =A0 "Function used to generate a `User-Agent:' string. If this is\r
+> =A0`nil' then no `User-Agent:' will be generated."\r
+> @@ -99,7 +127,8 @@ list."\r
+> =A0 =A0 =A0 =A0((same-window-regexps '("\\*mail .*")))\r
+> =A0 =A0 =A0 (notmuch-mua-mail (mail-header 'to headers)\r
+> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(mail-header 'subject head=\r
+ers)\r
+> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-headers-to-generat=\r
+e headers t '(to subject))))\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (message-headers-to-generat=\r
+e headers t '(to subject))\r
+> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 nil notmuch-mua-switch-func=\r
+tion))\r
+> =A0 =A0 ;; insert the message body - but put it in front of the signature\r
+> =A0 =A0 ;; if one is present\r
+> =A0 =A0 (goto-char (point-max))\r
+> @@ -112,6 +141,8 @@ list."\r
+> =A0 (message-goto-body))\r
+>\r
+> =A0(defun notmuch-mua-forward-message ()\r
+> + =A0(when notmuch-mua-switch-function\r
+> + =A0 =A0(funcall notmuch-mua-switch-function (current-buffer)))\r
+> =A0 (message-forward)\r
+>\r
+> =A0 (when notmuch-mua-user-agent-function\r
+> @@ -121,6 +152,7 @@ list."\r
+> =A0 (message-sort-headers)\r
+> =A0 (message-hide-headers)\r
+> =A0 (set-buffer-modified-p nil)\r
+> + =A0(set-window-dedicated-p (selected-window) notmuch-mua-dedicated-flag=\r
+)\r
+>\r
+> =A0 (message-goto-to))\r
+>\r
+> @@ -143,6 +175,7 @@ list."\r
+> =A0 (message-sort-headers)\r
+> =A0 (message-hide-headers)\r
+> =A0 (set-buffer-modified-p nil)\r
+> + =A0(set-window-dedicated-p (selected-window) notmuch-mua-dedicated-flag=\r
+)\r
+>\r
+> =A0 (message-goto-to))\r
+>\r
+> @@ -199,7 +232,7 @@ the From: address first."\r
+> =A0 (let ((other-headers\r
+> =A0 =A0 =A0 =A0 (when (or prompt-for-sender notmuch-always-prompt-for-sen=\r
+der)\r
+> =A0 =A0 =A0 =A0 =A0 (list (cons 'from (notmuch-mua-prompt-for-sender)))))=\r
+)\r
+> - =A0 =A0(notmuch-mua-mail nil nil other-headers)))\r
+> + =A0 =A0(notmuch-mua-mail nil nil other-headers nil notmuch-mua-switch-f=\r
+unction)))\r
+>\r
+> =A0(defun notmuch-mua-new-forward-message (&optional prompt-for-sender)\r
+> =A0 "Invoke the notmuch message forwarding window.\r
+> --\r
+> 1.7.7\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r