From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id A480E431FD2 for ; Sat, 4 Feb 2012 12:44:49 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0.201 X-Spam-Level: X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5EiZm2RT1Gku for ; Sat, 4 Feb 2012 12:44:48 -0800 (PST) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 7DE5E431FD5 for ; Sat, 4 Feb 2012 12:44:39 -0800 (PST) Received: by mail-we0-f181.google.com with SMTP id b10so4024656wer.26 for ; Sat, 04 Feb 2012 12:44:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=hdkgZUlD9Zrtxj6bogYYGvCVAH67HDTxhIxsZGhOnww=; b=OZg3rgcmsTaFbYB9l9XIGM8gaTEz6utuMlp6kffojhY+EPB4Vh8+3soP0GrP/8W7SH Q0Y56paeAKcZfbXMAiIe6MKGDa/mME6jiqaqdIUMDRcGDCZUm6M3dASkLFFTIAqYOo8z 60s4/0o4I85qEAAGocD2iOs6h203So50ZI0p0= Received: by 10.216.138.162 with SMTP id a34mr1189712wej.5.1328388279249; Sat, 04 Feb 2012 12:44:39 -0800 (PST) Received: from localhost (94-192-233-223.zone6.bethere.co.uk. [94.192.233.223]) by mx.google.com with ESMTPS id ho4sm14970370wib.3.2012.02.04.12.44.37 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 04 Feb 2012 12:44:38 -0800 (PST) From: Mark Walters To: notmuch@notmuchmail.org Subject: [PATCH v2 3/4] emacs: Improve prompting for user address when replying. Date: Sat, 4 Feb 2012 20:45:16 +0000 Message-Id: <1328388317-20161-4-git-send-email-markwalters1009@gmail.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1328388317-20161-1-git-send-email-markwalters1009@gmail.com> References: <1328388317-20161-1-git-send-email-markwalters1009@gmail.com> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Feb 2012 20:44:50 -0000 This patch uses the new --from option to notmuch reply to allow it to prompt the user for the From: address in cases when the cli does not know the "correct" from address. If the cli does not it either uses the users default address or, if notmuch-always-prompt-for-sender is set, prompts the user. --- emacs/notmuch-mua.el | 47 ++++++++++++++++++++++++++++------------------- 1 files changed, 28 insertions(+), 19 deletions(-) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index 41f82c2..36e62f9 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -51,6 +51,24 @@ list." ;; +(defcustom notmuch-identities nil + "Identities that can be used as the From: address when composing a new message. + +If this variable is left unset, then a list will be constructed from the +name and addresses configured in the notmuch configuration file." + :type '(repeat string) + :group 'notmuch-send) + +(defcustom notmuch-always-prompt-for-sender nil + "Always prompt for the From: address when composing or forwarding a message. + +This is not taken into account when replying to a message, because in that case +the From: header is already filled in by notmuch." + :type 'boolean + :group 'notmuch-send) + +(defvar notmuch-mua-sender-history nil) + (defun notmuch-mua-user-agent-full () "Generate a `User-Agent:' string suitable for notmuch." (concat (notmuch-mua-user-agent-notmuch) @@ -75,7 +93,7 @@ list." (defun notmuch-mua-reply (query-string &optional sender reply-all) (let (headers body - (args '("reply"))) + (args '("reply" "--from=fallback-received"))) (if notmuch-show-process-crypto (setq args (append args '("--decrypt")))) (if reply-all @@ -99,6 +117,15 @@ list." ;; If sender is non-nil, set the From: header to its value. (when sender (mail-header-set 'from sender headers)) + ;; If we do not have a From: header yet it means that + ;; notmuch-reply.c was not able to make a useful guess so we fill + ;; it in ourselves. + (when (string= "" (mail-header 'from headers)) + (if notmuch-always-prompt-for-sender + (setq sender (notmuch-mua-prompt-for-sender)) + (setq sender (concat + (notmuch-user-name) " <" (notmuch-user-primary-email) ">"))) + (mail-header-set 'from sender headers)) (let ;; Overlay the composition window on that being used to read ;; the original message. @@ -153,24 +180,6 @@ OTHER-ARGS are passed through to `message-mail'." (message-goto-to)) -(defcustom notmuch-identities nil - "Identities that can be used as the From: address when composing a new message. - -If this variable is left unset, then a list will be constructed from the -name and addresses configured in the notmuch configuration file." - :type '(repeat string) - :group 'notmuch-send) - -(defcustom notmuch-always-prompt-for-sender nil - "Always prompt for the From: address when composing or forwarding a message. - -This is not taken into account when replying to a message, because in that case -the From: header is already filled in by notmuch." - :type 'boolean - :group 'notmuch-send) - -(defvar notmuch-mua-sender-history nil) - (defun notmuch-mua-prompt-for-sender () (interactive) (let (name addresses one-name-only) -- 1.7.2.3