From: David Belohrad Date: Wed, 29 Oct 2014 13:09:12 +0000 (+0100) Subject: Re: [O] how to put into a journal info about the email sent X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d6894735dff1470db8904306aed917b495e6ab61;p=notmuch-archives.git Re: [O] how to put into a journal info about the email sent --- diff --git a/97/6894d34138aff49676ec6ae3e35aaf74b818b5 b/97/6894d34138aff49676ec6ae3e35aaf74b818b5 new file mode 100644 index 000000000..0d14e82cc --- /dev/null +++ b/97/6894d34138aff49676ec6ae3e35aaf74b818b5 @@ -0,0 +1,169 @@ +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 06AA9431FC2 + for ; Wed, 29 Oct 2014 06:09:27 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + 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 hn0l+g7BJXhd for ; + Wed, 29 Oct 2014 06:09:18 -0700 (PDT) +Received: from beesknees.cern.ch (beesknees.cern.ch [137.138.197.99]) + (using TLSv1 with cipher AES128-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id C8F30431FB6 + for ; Wed, 29 Oct 2014 06:09:18 -0700 (PDT) +Received: from belohrad by beesknees.cern.ch with local (Exim 4.84) + (envelope-from ) + id 1XjSzx-0003Sd-1n; Wed, 29 Oct 2014 14:09:13 +0100 +From: David Belohrad +To: Eric Abrahamsen , notmuch@notmuchmail.org +Subject: Re: [O] how to put into a journal info about the email sent +In-Reply-To: <87a94lh04t.fsf@ericabrahamsen.net> +References: + <87ppdhh3rh.fsf@ericabrahamsen.net> + + <87a94lh04t.fsf@ericabrahamsen.net> +User-Agent: Notmuch/0.18~rc0+2~gbc64cdc (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Wed, 29 Oct 2014 14:09:12 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain +Cc: emacs-orgmode@gnu.org +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: Wed, 29 Oct 2014 13:09:27 -0000 + +dear all, + +thanks for fruitful hints. Based on what you've done I have setup it as +follows: + +1) the capture template, which uses clipboard buffer to setup the + data. So my org-capture-templates contains this entry: + + ("@" "Email outgoing sync. USED INTERNALLY" entry (file+datetree (concat my-org-files "emails_sent.org")) + "* EMAIL %c :EMAIL:\n%?\nEntered on %T\n") + +2) function which generates the notmuch link based on the message id: + + (defun org-notmuch-track-outgoing-emails() + (save-restriction + (message-narrow-to-headers) + (let ((link (mail-fetch-field "Message-ID")) + (subject (mail-fetch-field "Subject")) + (to (mail-fetch-field "To")) + (date (mail-fetch-field "Date")) + (msg-id (mail-fetch-field "Message-ID")) + ;; `mail-fetch-field'. Construct date-ts and date-ts-ia with + ;;(date-ts (format-time-string (org-time-stamp-format t [t]) (date-to-time (mail-fetch-field "Date")))) + ) + (if link + ;; messageid exists, we can link it + (kill-new (concat "[[notmuch:id:" msg-id "][" subject "]]"))) + ;; use special template to fill in + (org-capture nil "@") + ) + ) + ) + +3) hook to run the function when headers are created: + +(add-hook 'message-header-hook 'org-notmuch-track-outgoing-emails) + + + +The three what they do is that whenever I send an email, a new diary +style entry is setup in the editting buffer, where the timestamp, email +link and an EMAIL tag are already pre-filled. So unless I want to add +another tags, sending email is by default a -two times- C-c C-c combo. + +Bettern than nothing, but still far from being perfect due to two +things: + +- 'standard' behaviour is, that the email sent becomes read-only so with + 'q' keystroke I can bury the buffer with the email. However when I + have implemented this, I have noticed that when I 'confirm' the + template, I go back into the buffer 'sent mail to...', but this the + *THE BUFFER IS NOT READ ONLY* and 'q' will just generate a character, + and then I have to kill this buffer using C-x k with additional 'yes' + because the buffer was modified. Quite annoying and I don't know how + to resolve this + +- second thing is, that I'd like to avoid at all opening the capture + template and just dump it into the file without any modifications + ongoing. The only 'modification' which comes into my mind is a setup + of an additional tag describing the email being attached to some + project... + +Any help on those two is highly appreciated :) + +.d. + + + +Eric Abrahamsen writes: + +> David Edmondson writes: +> +>> On Fri, Oct 24 2014, Eric Abrahamsen wrote: +>>> David Belohrad writes: +>>> +>>>> Dear All, +>>>> +>>>> i'm using org. And I'm using notmuch (that's why I address both mailing +>>>> lists). Now, writing an email in everyday bussiness requires a +>>>> non-significant time of your workhours. So I'd like to have this event +>>>> in my org agenda. So any time I send some email with a given subject, +>>>> I'd like to 'automatically' entry the information about it into +>>>> e.g. sentmails.org in form of a diary entry, with appropriate tag. +>>> +>>> I do something like this in Gnorb, which I'd recommend you use except +>>> it's mostly Gnus specific. +>>> +>>> I do it in two parts, but you could do it in one. Basically I add a +>>> function to the `message-header-hook' (which ensures that all the +>>> message headers have been generated properly). +>> +>> Does `message-generate-headers-first' not do what you want for this +>> specific part? +> +> Yeah, I think I looked at that previously. But this thing is going in a +> hook anyway, might as well use the hook that *doesn't* require me to +> call that function explicitly. +> +>>> Obviously the downside is that, without a "Gcc:" header, org can't +>>> actually make a real link to the message. It doesn't know where it's +>>> going to be. However if you know that all your sent messages can be +>>> reached with a link that looks like "notmuch:id#Message-id", then you +>>> can make that yourself in your org capture template with something like +>> +>> As you suggest, know the message-id should be good enough to generate a +>> notmuch link, though you may have to wait for the notmuch index to be +>> updated for the link to be valid. +> +> Yup, I've got the same issue with nnimap -- you have to wait for the +> next sync to get access to the message. So far it hasn't been a problem, +> though. +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch