From mboxrd@z Thu Jan 1 00:00:00 1970 From: "bva@alexanderonline.org" Subject: Re: processing pending emails as part of your GTD system Date: Wed, 23 Apr 2008 16:34:32 +0100 Message-ID: <23F0EFFE-B44D-433C-9C9B-6A6576516020@alexanderonline.org> Mime-Version: 1.0 (Apple Message framework v919.2) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jogzb-000871-Qc for emacs-orgmode@gnu.org; Wed, 23 Apr 2008 11:34:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JogzY-00085h-O1 for emacs-orgmode@gnu.org; Wed, 23 Apr 2008 11:34:43 -0400 Received: from [199.232.76.173] (port=52294 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JogzY-00085a-Jp for emacs-orgmode@gnu.org; Wed, 23 Apr 2008 11:34:40 -0400 Received: from harley.gnservers.com ([72.52.242.16]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JogzW-0007oy-F6 for emacs-orgmode@gnu.org; Wed, 23 Apr 2008 11:34:40 -0400 Received: from [82.77.174.10] (helo=Gigi.bavaria2.lan) by harley.gnservers.com with esmtp (Exim 4.68) (envelope-from ) id 1JogzO-0005ud-Hg for emacs-orgmode@gnu.org; Wed, 23 Apr 2008 11:34:31 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org On 2008-04-23 Wed, at 14:05, emacs-orgmode-request@gnu.org wrote: > > Message: 3 > Date: Tue, 22 Apr 2008 12:55:55 -0400 > From: Christopher League > Subject: Re: [Orgmode] processing pending emails as part of your GTD > system > To: org-mode mailing list > Message-ID: <3D9B5F2E-A15C-45C6-AF49-8E0E62248936@contrapunctus.net> > 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 22.1.50.1 (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! -Ben {footnote} 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 () > (interactive) > (call-process "/usr/bin/osascript" nil t nil > "/home/league/Library/Scripts/Applications/Mail/Copy > Message for OrgMode.scpt") > (yank)) > (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 >