emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* small patch to org-mac-link (grab selected messages in Mail.app)
@ 2014-06-04 10:15 Alan Schmitt
  2014-06-06 14:58 ` Anthony Lander
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Schmitt @ 2014-06-04 10:15 UTC (permalink / raw)
  To: emacs-orgmode

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

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-mac-link.el-Tweak-AppleScript-to-grab-Mail.app-m.patch --]
[-- Type: text/x-patch, Size: 1930 bytes --]

From 17dfd1cbee7355016c04f8ae09e102813651db86 Mon Sep 17 00:00:00 2001
From: Alan Schmitt <alan.schmitt@polytechnique.org>
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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: small patch to org-mac-link (grab selected messages in Mail.app)
  2014-06-04 10:15 small patch to org-mac-link (grab selected messages in Mail.app) Alan Schmitt
@ 2014-06-06 14:58 ` Anthony Lander
  2014-06-07  7:35   ` Alan Schmitt
  0 siblings, 1 reply; 4+ messages in thread
From: Anthony Lander @ 2014-06-06 14:58 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

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

Hi Alan,

Thanks for the patch. It looks OK to me - can you please go ahead and apply
it to the file? Also, feel free to add your name to the contributor list at
the top of the file.

Thanks!

  -Anthony



On Wed, Jun 4, 2014 at 6:15 AM, Alan Schmitt <alan.schmitt@polytechnique.org
> wrote:

> 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
>
>

[-- Attachment #2: Type: text/html, Size: 1510 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: small patch to org-mac-link (grab selected messages in Mail.app)
  2014-06-06 14:58 ` Anthony Lander
@ 2014-06-07  7:35   ` Alan Schmitt
  2014-06-07 13:32     ` Anthony Lander
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Schmitt @ 2014-06-07  7:35 UTC (permalink / raw)
  To: Anthony Lander; +Cc: emacs-orgmode

On 2014-06-06 16:58, Anthony Lander <anthony@landerfamily.ca> writes:

> Hi Alan,
>
> Thanks for the patch. It looks OK to me - can you please go ahead and
> apply it to the file? Also, feel free to add your name to the
> contributor list at the top of the file.

Done and pushed.

Best,

Alan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: small patch to org-mac-link (grab selected messages in Mail.app)
  2014-06-07  7:35   ` Alan Schmitt
@ 2014-06-07 13:32     ` Anthony Lander
  0 siblings, 0 replies; 4+ messages in thread
From: Anthony Lander @ 2014-06-07 13:32 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

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

Many thanks, Alan.


On Sat, Jun 7, 2014 at 3:35 AM, Alan Schmitt <alan.schmitt@polytechnique.org
> wrote:

> On 2014-06-06 16:58, Anthony Lander <anthony@landerfamily.ca> writes:
>
> > Hi Alan,
> >
> > Thanks for the patch. It looks OK to me - can you please go ahead and
> > apply it to the file? Also, feel free to add your name to the
> > contributor list at the top of the file.
>
> Done and pushed.
>
> Best,
>
> Alan
>

[-- Attachment #2: Type: text/html, Size: 868 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-06-07 13:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-04 10:15 small patch to org-mac-link (grab selected messages in Mail.app) Alan Schmitt
2014-06-06 14:58 ` Anthony Lander
2014-06-07  7:35   ` Alan Schmitt
2014-06-07 13:32     ` Anthony Lander

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).