emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Christopher Suckling <suckling.list@googlemail.com>
To: Carsten Dominik <dominik@science.uva.nl>
Cc: emacs-orgmode Mailinglist <emacs-orgmode@gnu.org>,
	Christopher Suckling <suckling.list@googlemail.com>
Subject: Re: [ANN] OS X only: Insert links to flagged emails
Date: Fri, 27 Mar 2009 10:30:28 +0100	[thread overview]
Message-ID: <7BBA0982-52F0-4155-9CCB-2BE29B36127E@gmail.com> (raw)
In-Reply-To: <8B72E954-171B-4965-9919-8A0C64621CD2@uva.nl>

[-- Attachment #1: Type: text/plain, Size: 450 bytes --]


On 22 Mar 2009, at 16:04, Carsten Dominik wrote:

> Applied, thanks.
>
> Would you like to write a short description/manual of org-mac- 
> message.el for
>
> http://orgmode.org/worg/org-contrib/
>
> ?
>

Hopefully I got everything right first time and the manual is making  
it's way to Worg as I write.

Meanwhile, I've rewritten some of the org-mac-message.el code to  
better handle multiple selections in Mail.app. Patch attached.

Christopher


[-- Attachment #2: org-mac-message.patch --]
[-- Type: application/octet-stream, Size: 2556 bytes --]

diff --git a/lisp/org-mac-message.el b/lisp/org-mac-message.el
index f8c4de2..9abcb58 100644
--- a/lisp/org-mac-message.el
+++ b/lisp/org-mac-message.el
@@ -4,6 +4,7 @@
 
 ;; Author: John Wiegley <johnw@gnu.org>
 ;;         Christopher Suckling <suckling at gmail dot com>
+
 ;; Version: 6.24trans
 ;; Keywords: outlines, hypermedia, calendar, wp
 
@@ -85,24 +86,47 @@ This will use the command `open' with the message URL."
 This will use applescript to get the message-id and the subject of the
 active mail in AppleMail and make a link out of it."
   (interactive)
-  (insert (org-mac-message-get-link)))
+  (org-mac-message-get-link)
+  (yank))
 
 (defun org-mac-message-get-link ()
   "Insert a link to the messages currently selected in Apple Mail.
 This will use applescript to get the message-id and the subject of the
 active mail in AppleMail and make a link out of it."
-  (let ((subject (do-applescript "tell application \"Mail\"
-	set theMessages to selection
-	subject of beginning of theMessages
-end tell"))
-	(message-id (do-applescript "tell application \"Mail\"
-	set theMessages to selection
-	message id of beginning of theMessages
-end tell")))
-    (org-make-link-string
-     (concat "message://"
-	     (substring message-id 1 (1- (length message-id))))
-     (substring subject 1 (1- (length subject))))))
+  (let* ((as-link-list
+	  (do-applescript
+	   (concat
+	    "tell application \"Mail\"\n"
+	    "set theLinkList to {}\n"
+	    "set theSelection to selection\n"
+	    "repeat with theMessage in theSelection\n"
+	    "set theID to message id of theMessage\n"
+	    "set theSubject to subject of theMessage\n"
+	    "set theLink to \"message://\" & theID & \"::split::\" & theSubject & \"\n\"\n"
+	    "copy theLink to end of theLinkList\n"
+	    "end repeat\n"
+	    "return theLinkList as string\n"
+	    "end tell")))
+	 (link-list (split-string as-link-list "\n"))
+	 split-link
+	 URL
+	 description
+	 orglink
+	 orglink-insert
+	 (orglink-list nil))
+    (while link-list
+      (progn
+	(setq split-link (split-string (pop link-list) "::split::"))
+	(setq URL (car split-link))
+	(setq description (cadr split-link))
+	(if (not (string= URL ""))
+	    (progn
+	      (setq orglink (org-make-link-string URL description))
+	      (push orglink orglink-list)))))
+    (with-temp-buffer      
+      (while orglink-list
+	(insert (concat (pop orglink-list)) "\n"))
+      (kill-region (point-min) (point-max)))))
 
 (defun org-mac-create-flagged-mail ()
   "Create links to flagged messages in a Mail.app account and

[-- Attachment #3: Type: text/plain, Size: 1 bytes --]



[-- Attachment #4: Type: text/plain, Size: 204 bytes --]

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2009-03-27  9:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-19 19:07 [ANN] OS X only: Insert links to flagged emails Christopher Suckling
2009-03-20 20:13 ` Carsten Dominik
2009-03-20 23:22   ` Christopher Suckling
2009-03-21 12:25     ` Carsten Dominik
2009-03-22 10:36       ` Christopher Suckling
2009-03-22 15:04         ` Carsten Dominik
2009-03-27  9:30           ` Christopher Suckling [this message]
2009-03-27  9:55             ` Carsten Dominik

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=7BBA0982-52F0-4155-9CCB-2BE29B36127E@gmail.com \
    --to=suckling.list@googlemail.com \
    --cc=dominik@science.uva.nl \
    --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).