From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Schmitt Subject: Re: PATCH: Fix malformed "message" links produced by org-mac-link.el Date: Thu, 09 Oct 2014 14:15:41 +0200 Message-ID: References: <35ACE9A2-E7B9-41DC-A748-13022BC1FABC@sanityinc.com> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcCdO-0000Ew-3a for emacs-orgmode@gnu.org; Thu, 09 Oct 2014 08:15:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XcCdI-0005RB-PI for emacs-orgmode@gnu.org; Thu, 09 Oct 2014 08:15:54 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:32861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcCdI-0005Qp-Ci for emacs-orgmode@gnu.org; Thu, 09 Oct 2014 08:15:48 -0400 In-Reply-To: (Alan Schmitt's message of "Thu, 25 Sep 2014 08:14:17 +0200") 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: Steve Purcell Cc: emacs-orgmode@gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Steve, On 2014-09-25 08:14, Alan Schmitt writes: > On 2014-09-24 20:56, Steve Purcell writes: > >> On 24 Sep 2014, at 20:01, Alan Schmitt = wrote: >> >>> This was the case here: the string returned by the AppleScript had >>> quotes (and it still does). >>>=20 >>> For instance, with the message you mention, the call to >>> org-as-get-selected-mail returns this (doing a debug): >>>=20 >>> Result: "\"message://2.b2af716655bbac583727@NY-WEB01::split::Private be= ta invitation for Emacs Q&A site - Area 51 - Stack Exchange\=E2=80=9D=E2=80= =9D >> >> >> I definitely don=E2=80=99t get quotes in the result of org-as-get-select= ed-mail. > > =E2=80=A6 > >> Not sure how to proceed, then=E2=80=A6 > > It seems that the difference is with getting quotes or not. How about > changing org-as-get-selected-mail to make sure there is no quote? We > could for instance test whether the first and last characters are > quotes, and remove them if they are. Would this work for you? Alan --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-mac-link.el-Fix-malformed-message-links.patch Content-Transfer-Encoding: quoted-printable From=20c6c1a05894e6fb1698d1a12bb2dc6a47874169f6 Mon Sep 17 00:00:00 2001 From: Alan Schmitt Date: Thu, 9 Oct 2014 14:12:05 +0200 Subject: [PATCH] org-mac-link.el: Fix malformed message links * contrib/lisp/org-mac-link.el (org-mac-message-get-links): Fix and use the= `org-mac-paste-applescript-links' helper. The existing code inserted links which should have been "[[message:ABC][the= subject]]" as "[[essage:ABC][the subjec]]". Based on a patch by Steve Purcell . =2D-- contrib/lisp/org-mac-link.el | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el index 979fb18..e1ab56d 100644 =2D-- a/contrib/lisp/org-mac-link.el +++ b/contrib/lisp/org-mac-link.el @@ -234,11 +234,15 @@ When done, go grab the link, and insert it at point." (defun org-mac-paste-applescript-links (as-link-list) "Paste in a list of links from an applescript handler. The links are of the form ::split::." =2D (let* ((link-list + (let* ((noquote-as-link-list=20 + (if (string-prefix-p "\"" as-link-list)=20 + (substring as-link-list 1 -1)=20 + as-link-list)) + (link-list (mapcar (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x) (setq x (match-string 1 x))) x) =2D (split-string as-link-list "[\r\n]+"))) + (split-string noquote-as-link-list "[\r\n]+"))) split-link URL description orglink orglink-insert rtn orglink-lis= t) (while link-list (setq split-link (split-string (pop link-list) "::split::")) @@ -828,27 +832,11 @@ The Org-syntax text will be pushed to the kill ring, = and also returned." (interactive "sLink to (s)elected or (f)lagged messages: ") (setq select-or-flag (or select-or-flag "s")) (message "AppleScript: searching mailboxes...") =2D (let* ((as-link-list =2D (if (string=3D select-or-flag "s") =2D (org-as-get-selected-mail) =2D (if (string=3D select-or-flag "f") =2D (org-as-get-flagged-mail) =2D (error "Please select \"s\" or \"f\"")))) =2D (link-list =2D (mapcar =2D (lambda (x) (if (string-match "\\`\"\\(.*\\)\"\\'" x) (setq x= (match-string 1 x))) x) =2D (split-string (substring as-link-list 1 -1) "[\r\n]+"))) =2D split-link URL description orglink orglink-insert rtn orglink-l= ist) =2D (while link-list =2D (setq split-link (split-string (pop link-list) "::split::")) =2D (setq URL (car split-link)) =2D (setq description (cadr split-link)) =2D (when (not (string=3D URL "")) =2D (setq orglink (org-make-link-string URL description)) =2D (push orglink orglink-list))) =2D (setq rtn (mapconcat 'identity orglink-list "\n")) =2D (kill-new rtn) =2D rtn)) + (org-mac-paste-applescript-links + (cond + ((string=3D select-or-flag "s") (org-as-get-selected-mail)) + ((string=3D select-or-flag "f") (org-as-get-flagged-mail)) + (t (error "Please select \"s\" or \"f\""))))) =20 (defun org-mac-message-insert-selected () "Insert a link to the messages currently selected in Mail.app. =2D-=20 2.1.2 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D-=20 OpenPGP Key ID : 040D0A3B4ED2E5C7 --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) iQEcBAEBCgAGBQJUNnxyAAoJEAQNCjtO0uXHpqsH/AhIM2RqHVUmn4Qlusulu+YR qa9F0LMjRlZ7W9zA86ZJB7LxlV+KgKFgagUJrQkynS5YwBSgbr1hBZaUvk6lBBn8 x/eLgez3zxR2A0GXbE94sKOlkP5xmoIZRlwT2oKdEBwHapgmgppWvYXhUuRBx1Jy 5NP9JJPEMrEvA1pxUrWI5X2qtWMR8q8mZ2Ghm9zJI6fP/qJNx9o5h3cCd8jxqDQH yT1dJuygEUMKlt3vqWT9IQ/qQah48FWzTpn3c/AmYIRY2Q1bvEVjrt+Vzlrna5X1 +M9ALkYbqYKCUP/NbIW5ylm2kxl8B4mO9vEP0czfRk/sLop51GMejqVnRqHvvJU= =nybN -----END PGP SIGNATURE----- --==-=-=--