[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] processing pending emails as part of your GTD system

From: address@hidden
Subject: Re: [Orgmode] processing pending emails as part of your GTD system
Date: Wed, 23 Apr 2008 16:34:32 +0100

On 2008-04-23 Wed, at 14:05, address@hidden wrote:

Message: 3
Date: Tue, 22 Apr 2008 12:55:55 -0400
From: Christopher League <address@hidden>
Subject: Re: [Orgmode] processing pending emails as part of your GTD
To: org-mode mailing list <address@hidden>
Message-ID: <address@hidden>
Content-Type: text/plain; charset="us-ascii"

More relevant to org-mode, I have an emacs-lisp/apple-script combo for
pasting links to Apple Mail messages into org files:

Wow.  Thank you very much for this.

I've tried to do something like this, but I'm a read-only coder.

I've been using Apple's Mail program since I got my first Mac 5 years ago, and only recently (since 2007-08) started using GTD and org- mode. I've been very frustrated by some of the time-consuming choices I've made to keep Mail and 'projects.org' linked.

How did you know about this ``message://%3c%3e'' schema syntax!? Is there anything else I can do to Mail from within Emacs (or from within Quicksilver {see footnote}). Where can I read more! Is it safe to upgrade Mail (i.e. if I upgrade to OS X 10.666 will this script break?) It seems that the message is found even if I move it to another folder within Mail after generating the link; anything I need to be warned about? I often have two message viewers open (one with mailboxes showing and one without, for easier filing {see footnote}) -- how does your script (or Mail) choose which one is 'selected'?

That's a lot questions ... feel free to redirect me to a resource to read first instead of taking your time repeating well-known details of Mail's internals. It's just that the Dictionary of Mail (in Script Editor) isn't very comprehensible to me. I don't speak AppleScript.

Two issues with the the emacs-lisp and applescript.

1) Why doesn't the applescript work for the messages in the first folder I tried - my GTD folder? Messages from the org-mode digest are automatically filed to "On My Mac" -> "Reference" -> "GHI" -> "GTD" to help keep my inbox clean. But any message I try to run your script on gives me blank "id" properties.

Example: [[message://%3c%3e][Emacs-orgmode Digest, Vol 26, Issue 54]]

when I click on this link in my org-mode file, Mail generates an error dialog with the message "No associated application could be found."

Every other message in any other folder I've tried works fine. Strange.

2) The emacs-lisp code calls (yank) which doesn't grab text from the Apple Clipboard for me. I am using "GNU Emacs (powerpc- apple-darwin7.9.0, Carbon Version 1.6.0) of 2007-10-02 on applecore.inf.ed.ac.uk - Aquamacs Distribution 1.2a" and org-version 5.23a. Instead, I modified your code to use (cua-paste).

Now I've just got to figure out where to put this code! Thank you ever so much!


I've tried to select multiple messages in Mail and then use Quicksilver to re-file them all in one go. I tested this (I thought) then spent hours creating a whole 'Reference' folder hierarchy. But it just doesn't work! If I could find a way for the currently selected messages to be passed to Quicksilver AND also use quicksilver to select the folders (the search capabilities are great!) maybe I could cobble something together.

Right now, I've decided that spending time to automate this isn't worth the time saved.

{end footnote}

(defun cal-grab-mail-links ()
  (call-process "/usr/bin/osascript" nil t nil
Message for OrgMode.scpt")
(define-key org-mode-map "\C-cm" 'cal-grab-mail-links)

;;;;; and the .scpt component:

-- Replace all occurences of one string for another in a text
-- The trick here is to change the internal delimiter,
-- spliting and joining the text
on replaceString(theText, oldString, newString)
        set AppleScript's text item delimiters to oldString
        set tempList to every text item of theText
        set AppleScript's text item delimiters to newString
        set theText to the tempList as string
        set AppleScript's text item delimiters to ""
        return theText
end replaceString

tell application "Mail"
        set _sel to get selection
        set _links to {}
        repeat with _msg in _sel
                set _subj to _msg's subject
                set _subj to my replaceString(_subj, "[", "(")
                set _subj to my replaceString(_subj, "]", ")")
                set _messageURL to "[[message://%3c" & _msg's message id & "%3e][" 
_subj & "]]"
                set end of _links to _messageURL
        end repeat
        set AppleScript's text item delimiters to return
        set the clipboard to (_links as string)
end tell

reply via email to

[Prev in Thread] Current Thread [Next in Thread]