emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "bva@alexanderonline.org" <bva@alexanderonline.org>
To: emacs-orgmode@gnu.org
Subject: Re: processing pending emails as part of your GTD 	system
Date: Wed, 23 Apr 2008 16:34:32 +0100	[thread overview]
Message-ID: <23F0EFFE-B44D-433C-9C9B-6A6576516020@alexanderonline.org> (raw)


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 <league@contrapunctus.net>
> Subject: Re: [Orgmode] processing pending emails as part of your GTD
> 	system
> To: org-mode mailing list <emacs-orgmode@gnu.org>
> 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
>

             reply	other threads:[~2008-04-23 15:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-23 15:34 bva [this message]
2008-04-24  3:38 ` processing pending emails as part of your GTD system Christopher League
  -- strict thread matches above, loose matches on Subject: below --
2008-04-21  6:55 Pete Phillips
2008-04-22 16:55 ` Christopher League
2008-04-23 19:25 ` Erik Hetzner
2008-04-30 21:25 ` Adam Spiers
2008-05-01  6:32   ` Carsten Dominik
2008-05-03 21:32     ` Adam Spiers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23F0EFFE-B44D-433C-9C9B-6A6576516020@alexanderonline.org \
    --to=bva@alexanderonline.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).