From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: small patch to org-mac-link (grab selected messages in Mail.app) Date: Wed, 04 Jun 2014 12:15:55 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ws8Eo-0002w1-LF for emacs-orgmode@gnu.org; Wed, 04 Jun 2014 06:16:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ws8Eh-0005Tf-Tg for emacs-orgmode@gnu.org; Wed, 04 Jun 2014 06:16:06 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:16909) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ws8Eh-0005S3-Md for emacs-orgmode@gnu.org; Wed, 04 Jun 2014 06:15:59 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode --=-=-= Content-Type: text/plain Hello, Please find attached a small patch to org-mac-link.el for the functions creating links to messages in Mail.app. The problem was that calling the org-mac-message-insert-selected would always add a spurious first link with empty url and an escaped quote as text. It would also leave another escaped quote at the end of the text of the real link. The patch makes sure that no extra empty line is created during the AppleScript call, and removes the escaped quotes around the whole value returned from AppleScript. I have left the code that removes additional quotes around individual links if they are there, but I don't think it's needed (I don't see how they could occur there). Best, Alan --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-mac-link.el-Tweak-AppleScript-to-grab-Mail.app-m.patch >From 17dfd1cbee7355016c04f8ae09e102813651db86 Mon Sep 17 00:00:00 2001 From: Alan Schmitt Date: Wed, 4 Jun 2014 11:47:09 +0200 Subject: [PATCH] org-mac-link.el: Tweak AppleScript to grab Mail.app messages * contrib/lisp/org-mac-link.el (org-as-get-selected-mail): Make sure no extra new line is present in the string returned from the AppleScript. * contrib/lisp/org-mac-link.el (org-mac-message-get-links): Get rid of the enclosing quotes before splitting the string. --- contrib/lisp/org-mac-link.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el index d1687e0..99f141f 100644 --- a/contrib/lisp/org-mac-link.el +++ b/contrib/lisp/org-mac-link.el @@ -727,7 +727,10 @@ This will use the command `open' with the message URL." "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" + "set theLink to \"message://\" & theID & \"::split::\" & theSubject\n" + "if (theLinkList is not equal to {}) then\n" + "set theLink to \"\n\" & theLink\n" + "end if\n" "copy theLink to end of theLinkList\n" "end repeat\n" "return theLinkList as string\n" @@ -801,7 +804,7 @@ The Org-syntax text will be pushed to the kill ring, and also returned." (link-list (mapcar (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x) (setq x (match-string 1 x))) x) - (split-string as-link-list "[\r\n]+"))) + (split-string (substring as-link-list 1 -1) "[\r\n]+"))) split-link URL description orglink orglink-insert rtn orglink-list) (while link-list (setq split-link (split-string (pop link-list) "::split::")) -- 1.8.5.3 --=-=-=--