Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 084DA431FC1 for ; Thu, 22 Apr 2010 16:17:40 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -4.2 X-Spam-Level: X-Spam-Status: No, score=-4.2 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3] autolearn=unavailable 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 Tv5wto1EcjCL for ; Thu, 22 Apr 2010 16:17:37 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) by olra.theworths.org (Postfix) with ESMTP id D7CF74196F2 for ; Thu, 22 Apr 2010 16:17:37 -0700 (PDT) Received: from localhost ([::1] helo=x200.gr8dns.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1O55eK-0003vZ-VC; Thu, 22 Apr 2010 23:17:37 +0000 Received: by x200.gr8dns.org (Postfix, from userid 500) id 207D4C0249; Thu, 22 Apr 2010 16:17:36 -0700 (PDT) From: Dirk Hohndel To: Sebastian Spaeth , notmuch@notmuchmail.org Subject: Re: [notmuch] Fcc, Maildir, and Emacs message-mode -- a bit of code In-Reply-To: <87ochbx3er.fsf@SSpaeth.de> References: <873a1zs3t5.fsf@jhu.edu> <87ochbx3er.fsf@SSpaeth.de> Date: Thu, 22 Apr 2010 16:17:36 -0700 Message-ID: User-Agent: notmuch 0.2-183-g625ff29 (Emacs 23.1.1/i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html 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: Thu, 22 Apr 2010 23:17:40 -0000 On Thu, 22 Apr 2010 11:06:04 +0200, "Sebastian Spaeth" wrote: > As Carl stated that he would probably merge this one if someone tested > it, here it comes: I tested it and it works great. When I define a > non-existing directory as maildir it aborts with an error message that > is visible to the user. > > I put this in a branch based on cworth/master and with Jesse's > permission, I renamed the functions and did some further cleanup (It's > also integrated in the build system) > > The git branch is here: > http://github.com/spaetz/notmuch-all-feature/tree/feature/elisp-fcc > > It's not enabled by default. Enable it with: > > (setq message-fcc-handler-function > '(lambda (destdir) > (notmuch-maildir-fcc-write-buffer-to-maildir destdir t))) > > (add-hook 'message-send-hook > '(lambda () > (message-add-header "Fcc: ~/mail/INBOX.Sent"))) I am now using this patch together with this little snippet in my .emacs file to FCC into per-from-address specific sent folders ;; This is the list of alternatives that should be configurable as ;; defcustom (or simply set in .emacs for now) (setq notmuch-fcc-dirs '( ("Dirk Hohndel " . "Maildir/Sent Items") ("Dirk Hohndel " . "MaildirInfradead/Sent"))) ;This constructs a path, concatenating the content of the variable ;"message-directory" and the second part in the alist: (defun my-fcc-header-setup () (let ((subdir (cdr (assoc (message-fetch-field "from") notmuch-fcc-dirs)))) (message-add-header (concat "Fcc: " message-directory subdir)))) (add-hook 'message-send-hook 'my-fcc-header-setup) (setq message-fcc-handler-function '(lambda (destdir) (notmuch-maildir-fcc-write-buffer-to-maildir destdir t))) I am using the message-send-hook (instead of the message-header-setup-hook as Sebastian initially suggested) because I tend to edit the From line in my message buffer and want to make sure that it uses the final From line. Also, this way the FCC also works correctly with replies (the message-header-setup-hook doesn't get called by our notmuch-reply function, it seems). The disadvantage is that with the message-send-hook I don't get to see / correct the FCC line in the message buffer - but since I trust the logic here (and tested it quite a bit), I'm less concerned about this. Finally, for other emacs-newbies like me - this concats the message-directory variable with the path that you setup in the notmuch-fcc-dirs associative array... so the path to the sent folder needs to be relative to that. Carl - I'd love to see this in 0.3 /D -- Dirk Hohndel Intel Open Source Technology Center