From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id A0D856DE13F4 for ; Mon, 3 Aug 2015 00:46:16 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.852 X-Spam-Level: X-Spam-Status: No, score=-0.852 tagged_above=-999 required=5 tests=[AWL=-1.026, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_SBL=0.644, URIBL_SBL_A=0.1] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E1MEzIx-1lNm for ; Mon, 3 Aug 2015 00:46:12 -0700 (PDT) Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by arlo.cworth.org (Postfix) with ESMTPS id C30946DE13DB for ; Mon, 3 Aug 2015 00:46:11 -0700 (PDT) Received: by wibxm9 with SMTP id xm9so102121227wib.1 for ; Mon, 03 Aug 2015 00:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; bh=Ig3og0ZGp/ecJEDzBh4pH9V2ulJBzIR/Dh+lpmP82z0=; b=0MhARxu57tFtCmpu5tKrIbHW4nNRpSU+fz0f7AeXKP6TlUbUJGyGPfQIzJP2Y6Agfz m+Rg0UTDRncHYL8LtBZybnNMneXI0y2LYrzcAyTfAe+15mgG488lffEvGtKgjN7yizJm 23lEpvna9Rw0uueuAVf5Ck9aEeYG44VOFwmC6VzaRx8k+pmP5qbKJ5tKQ3+IRrNWkW9h frwT/w7LRuy/h3IML8h5ZXY/gcOnxLGazEd2W/HGdn7bKP8120H/XHh+9i3QRR8kwBMZ PvB8UuSvwPWokMDeWp4hxfHwfIPQD+ciZaED33aq1X6zmz3IZENqrLyL0EnjEX/xTZQp 3tSg== X-Received: by 10.194.190.79 with SMTP id go15mr30096970wjc.80.1438587969805; Mon, 03 Aug 2015 00:46:09 -0700 (PDT) Received: from localhost (188.29.71.109.threembb.co.uk. [188.29.71.109]) by smtp.gmail.com with ESMTPSA id s1sm12148134wix.13.2015.08.03.00.46.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2015 00:46:09 -0700 (PDT) From: Mark Walters To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 2/2] emacs: make modifications to message Fcc vars buffer-local In-Reply-To: <1438422296-29087-3-git-send-email-david@tethera.net> References: <87vbdrysd7.fsf@qmul.ac.uk> <1438422296-29087-1-git-send-email-david@tethera.net> <1438422296-29087-3-git-send-email-david@tethera.net> User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Mon, 03 Aug 2015 08:46:05 +0100 Message-ID: <873800yfuq.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.18 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: Mon, 03 Aug 2015 07:46:16 -0000 On Sat, 01 Aug 2015, David Bremner wrote: > Previously we globally modified these variables, which tended to cause > problems for people using message-mode, but not notmuch-mua-mail, to > send mail. I think I like this approach: I think we will like the freedom to tweak message-mode. > User visible changes: > > - calling notmuch-fcc-header-setup is no longer optional. OTOH, it > seems to do the right thing if notmuch-fcc-dirs is set to nil. > > - the Fcc header is visible during message composition These both seem good. At the moment notmuch-fcc-header-setup checks whether the fcc directory is a valid maildir. This used to be called on sending but is now called when the message composition is started. I think it would be better to move it into notmuch-mua-send-and-exit or (perhaps better) in notmuch-fcc-handler itself (in case the user edits it). > - the name in the mode line is changed, and (sadface) no longer > matches the menu label. Do you mean the buffer name is *mail*? We could just call rename-buffer somewhere (maybe in our derived mode bit?) > - Previously notmuch-mua-send-and-exit was never called. Either we > misunderstood define-mail-user-agent, or it had a bug. So there was > no difference if the user called message-send-and-exit directly. Now > there will be. This is a little irritating in case people have customised key bindings but I don't see a way round it. A related case, which we probably should fix, is that C-c C-s is bound to message send (and don't exit), this probably needs a wrapper too. Best wishes Mark > --- > emacs/notmuch-maildir-fcc.el | 23 +++++++++-------------- > emacs/notmuch-mua.el | 6 +++++- > test/test-lib.sh | 4 ++-- > 3 files changed, 16 insertions(+), 17 deletions(-) > > diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el > index 07eedba..c2f2f4c 100644 > --- a/emacs/notmuch-maildir-fcc.el > +++ b/emacs/notmuch-maildir-fcc.el > @@ -59,23 +59,19 @@ yet when sending a mail." > :require 'notmuch-fcc-initialization > :group 'notmuch-send) > > -(defun notmuch-fcc-initialization () > - "If notmuch-fcc-directories is set, > - hook them into the message-fcc-handler-function" > - ;; Set up the message-fcc-handler to move mails to the maildir in Fcc > - ;; The parameter is set to mark messages as "seen" > - (setq message-fcc-handler-function > - (lambda (destdir) > - (notmuch-maildir-fcc-write-buffer-to-maildir destdir t))) > - ;; add a hook to actually insert the Fcc header when sending > - (add-hook 'message-header-setup-hook 'notmuch-fcc-header-setup)) > +(defun notmuch-fcc-handler (destdir) > + "Write buffer to `destdir', marking it as sent > + > +Intended to be dynamically bound to `message-fcc-handler-function'" > + (notmuch-maildir-fcc-write-buffer-to-maildir destdir t)) > > (defun notmuch-fcc-header-setup () > "Add an Fcc header to the current message buffer. > > -Can be added to `message-send-hook' and will set the Fcc header > -based on the values of `notmuch-fcc-dirs'. An existing Fcc header > -will NOT be removed or replaced." > +Sets the Fcc header based on the values of `notmuch-fcc-dirs'. > + > +Originally intended to be use a hook function, but now called directly > +by notmuch-mua-mail" > > (let ((subdir > (cond > @@ -213,6 +209,5 @@ return t if successful, and nil otherwise." > (delete-file (concat destdir "/tmp/" msg-id)))) > t))) > > -(notmuch-fcc-initialization) > (provide 'notmuch-maildir-fcc) > > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el > index a7d3eaa..4ae7d1e 100644 > --- a/emacs/notmuch-mua.el > +++ b/emacs/notmuch-mua.el > @@ -268,6 +268,8 @@ Note that these functions use `mail-citation-hook' if that is non-nil." > (define-derived-mode notmuch-compose-mode message-mode "notmuch-compose" > "Notmuch message composition mode. Mostly like `message-mode'") > > +(define-key notmuch-compose-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit) > + > (defun notmuch-mua-mail (&optional to subject other-headers &rest other-args) > "Invoke the notmuch mail composition window. > > @@ -285,6 +287,7 @@ OTHER-ARGS are passed through to `message-mail'." > > (apply #'message-mail to subject other-headers other-args) > (notmuch-compose-mode) > + (notmuch-fcc-header-setup) > (message-sort-headers) > (message-hide-headers) > (set-buffer-modified-p nil) > @@ -398,7 +401,8 @@ will be addressed to all recipients of the source message." > > (defun notmuch-mua-send-and-exit (&optional arg) > (interactive "P") > - (message-send-and-exit arg)) > + (let ((message-fcc-handler-function #'notmuch-fcc-handler)) > + (message-send-and-exit arg))) > > (defun notmuch-mua-kill-buffer () > (interactive) > diff --git a/test/test-lib.sh b/test/test-lib.sh > index 3466e9c..cb8a6cf 100644 > --- a/test/test-lib.sh > +++ b/test/test-lib.sh > @@ -487,7 +487,7 @@ emacs_deliver_message () > (message-goto-body) > (insert \"${body}\") > $@ > - (message-send-and-exit))" > + (notmuch-mua-send-and-exit))" > > # In case message was sent properly, client waits for confirmation > # before exiting and resuming control here; therefore making sure > @@ -522,7 +522,7 @@ emacs_fcc_message () > (message-goto-body) > (insert \"${body}\") > $@ > - (message-send-and-exit))" || return 1 > + (notmuch-mua-send-and-exit))" || return 1 > notmuch new >/dev/null > } > > -- > 2.1.4