emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* PATCH: org-mac-link.el: Don't fail on machines without Growl installed
@ 2014-09-24 11:12 Steve Purcell
  2014-09-24 15:38 ` Alan Schmitt
  2014-10-09 11:40 ` Alan Schmitt
  0 siblings, 2 replies; 11+ messages in thread
From: Steve Purcell @ 2014-09-24 11:12 UTC (permalink / raw)
  To: emacs-orgmode

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

The existing Applescript for grabbing flagged mail messages can only work on machines which have Growl installed. This is increasingly rarely the case as Growl has been obsoleted by OS X’s own notification system.

-Steve


[-- Attachment #2: 0001-org-mac-link.el-Don-t-fail-on-machines-without-Growl.patch --]
[-- Type: application/octet-stream, Size: 3393 bytes --]

From 3608ea50704a2479839b91bb1a92cacf453bae8c Mon Sep 17 00:00:00 2001
From: Steve Purcell <steve@sanityinc.com>
Date: Wed, 24 Sep 2014 12:07:20 +0100
Subject: [PATCH] org-mac-link.el: Don't fail on machines without Growl
 installed

* contrib/lisp/org-mac-link.el (org-as-get-flagged-mail): Don't assume Growl is installed.

Applescript can't run if it refers to uninstalled apps, so since Growl is not universally
installed, references to it should be dropped. This change also provides a less cryptic
message when `org-mac-mail-account' is unset at the time flagged messages are grabbed.

TINYCHANGE
---
 contrib/lisp/org-mac-link.el | 33 +++------------------------------
 1 file changed, 3 insertions(+), 30 deletions(-)

diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index 3b58d04..e05a67d 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -171,7 +171,7 @@
   :tag "Org Mail.app"
   :group 'org-link)
 
-(defcustom org-mac-mail-account "customize"
+(defcustom org-mac-mail-account nil
   "The Mail.app account in which to search for flagged messages."
   :group 'org-mac-flagged-mail
   :type 'string)
@@ -799,18 +799,10 @@ This will use the command `open' with the message URL."
 
 (defun org-as-get-flagged-mail ()
   "AppleScript to create links to flagged messages in Mail.app."
+  (unless org-mac-mail-account
+    (error "You must set org-mac-mail-account"))
   (do-applescript
    (concat
-    ;; Is Growl installed?
-    "tell application \"System Events\"\n"
-    "set growlHelpers to the name of every process whose creator type contains \"GRRR\"\n"
-    "if (count of growlHelpers) > 0 then\n"
-    "set growlHelperApp to item 1 of growlHelpers\n"
-    "else\n"
-    "set growlHelperApp to \"\"\n"
-    "end if\n"
-    "end tell\n"
-
     ;; Get links
     "tell application \"Mail\"\n"
     "set theMailboxes to every mailbox of account \"" org-mac-mail-account "\"\n"
@@ -822,25 +814,6 @@ This will use the command `open' with the message URL."
     "set theSubject to subject of theMessage\n"
     "set theLink to \"message://\" & theID & \"::split::\" & theSubject & \"\n\"\n"
     "copy theLink to end of theLinkList\n"
-
-    ;; Report progress through Growl
-    ;; This "double tell" idiom is described in detail at
-    ;; http://macscripter.net/viewtopic.php?id=24570 The
-    ;; script compiler needs static knowledge of the
-    ;; growlHelperApp.  Hmm, since we're compiling
-    ;; on-the-fly here, this is likely to be way less
-    ;; portable than I'd hoped.  It'll work when the name
-    ;; is still "GrowlHelperApp", though.
-    "if growlHelperApp is not \"\" then\n"
-    "tell application \"GrowlHelperApp\"\n"
-    "tell application growlHelperApp\n"
-    "set the allNotificationsList to {\"FlaggedMail\"}\n"
-    "set the enabledNotificationsList to allNotificationsList\n"
-    "register as application \"FlaggedMail\" all notifications allNotificationsList default notifications enabledNotificationsList icon of application \"Mail\"\n"
-    "notify with name \"FlaggedMail\" title \"Importing flagged message\" description theSubject application name \"FlaggedMail\"\n"
-    "end tell\n"
-    "end tell\n"
-    "end if\n"
     "end repeat\n"
     "end repeat\n"
     "return theLinkList as string\n"
-- 
2.1.1


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

* Re: PATCH: org-mac-link.el: Don't fail on machines without Growl installed
  2014-09-24 15:38 ` Alan Schmitt
@ 2014-09-24 15:35   ` Steve Purcell
  2014-09-24 19:13     ` Alan Schmitt
  0 siblings, 1 reply; 11+ messages in thread
From: Steve Purcell @ 2014-09-24 15:35 UTC (permalink / raw)
  To: emacs-orgmode

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> On 2014-09-24 12:12, Steve Purcell <steve@sanityinc.com> writes:
> I'm surprised: I don't have Growl installed and it still works. I agree
> there is not much point in testing for Growl, though.

I get the system popup asking me to locate the "growlHelperApp"
program.

-Steve

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

* Re: PATCH: org-mac-link.el: Don't fail on machines without Growl installed
  2014-09-24 11:12 PATCH: org-mac-link.el: Don't fail on machines without Growl installed Steve Purcell
@ 2014-09-24 15:38 ` Alan Schmitt
  2014-09-24 15:35   ` Steve Purcell
  2014-10-09 11:40 ` Alan Schmitt
  1 sibling, 1 reply; 11+ messages in thread
From: Alan Schmitt @ 2014-09-24 15:38 UTC (permalink / raw)
  To: Steve Purcell; +Cc: emacs-orgmode

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

On 2014-09-24 12:12, Steve Purcell <steve@sanityinc.com> writes:

> The existing Applescript for grabbing flagged mail messages can only
> work on machines which have Growl installed. This is increasingly
> rarely the case as Growl has been obsoleted by OS X’s own notification
> system.

I'm surprised: I don't have Growl installed and it still works. I agree
there is not much point in testing for Growl, though.

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: PATCH: org-mac-link.el: Don't fail on machines without Growl installed
  2014-09-24 15:35   ` Steve Purcell
@ 2014-09-24 19:13     ` Alan Schmitt
  2014-09-24 19:59       ` Steve Purcell
  0 siblings, 1 reply; 11+ messages in thread
From: Alan Schmitt @ 2014-09-24 19:13 UTC (permalink / raw)
  To: Steve Purcell; +Cc: emacs-orgmode

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

On 2014-09-24 16:35, Steve Purcell <steve@sanityinc.com> writes:

> Alan Schmitt <alan.schmitt@polytechnique.org> writes:
>
>> On 2014-09-24 12:12, Steve Purcell <steve@sanityinc.com> writes:
>> I'm surprised: I don't have Growl installed and it still works. I agree
>> there is not much point in testing for Growl, though.
>
> I get the system popup asking me to locate the "growlHelperApp"
> program.

Indeed. Digging a little, I found out that I actually have Growl still
installed. I removed it, killed its process, and made sure through the
following AppleScript that it's not found:

tell application "System Events"
	set growlHelpers to the name of every process whose creator type contains "GRRR"
	if (count of growlHelpers) > 0 then
		set growlHelperApp to item 1 of growlHelpers
	else
		set growlHelperApp to ""
	end if
end tell

I get an empty string as returned value. Is is the same for you?

But as I said before, I'm fine with removing Growl support, unless
someone objects.

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: PATCH: org-mac-link.el: Don't fail on machines without Growl installed
  2014-09-24 19:13     ` Alan Schmitt
@ 2014-09-24 19:59       ` Steve Purcell
  2014-09-25  6:17         ` Alan Schmitt
  0 siblings, 1 reply; 11+ messages in thread
From: Steve Purcell @ 2014-09-24 19:59 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

On 24 Sep 2014, at 20:13, Alan Schmitt <alan.schmitt@polytechnique.org> wrote:

> tell application "System Events"
> 	set growlHelpers to the name of every process whose creator type contains "GRRR"
> 	if (count of growlHelpers) > 0 then
> 		set growlHelperApp to item 1 of growlHelpers
> 	else
> 		set growlHelperApp to ""
> 	end if
> end tell
> 
> I get an empty string as returned value. Is is the same for you?


Yes, that part works fine on its own even on my machine. But when the code passed to AppleScript includes 'tell application “GrowlHelperApp”’, then the code will not execute unless the app is present — there’s a precompilation step where, presumably, AppleScript determines that the target application supports the listed commands.

-Steve

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

* Re: PATCH: org-mac-link.el: Don't fail on machines without Growl installed
  2014-09-24 19:59       ` Steve Purcell
@ 2014-09-25  6:17         ` Alan Schmitt
  2014-10-06  6:31           ` Alan Schmitt
  0 siblings, 1 reply; 11+ messages in thread
From: Alan Schmitt @ 2014-09-25  6:17 UTC (permalink / raw)
  To: Steve Purcell; +Cc: emacs-orgmode

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

On 2014-09-24 20:59, Steve Purcell <steve@sanityinc.com> writes:

> On 24 Sep 2014, at 20:13, Alan Schmitt <alan.schmitt@polytechnique.org> wrote:
>
>> tell application "System Events"
>> 	set growlHelpers to the name of every process whose creator type contains "GRRR"
>> 	if (count of growlHelpers) > 0 then
>> 		set growlHelperApp to item 1 of growlHelpers
>> 	else
>> 		set growlHelperApp to ""
>> 	end if
>> end tell
>> 
>> I get an empty string as returned value. Is is the same for you?
>
>
> Yes, that part works fine on its own even on my machine. But when the
> code passed to AppleScript includes 'tell application
> “GrowlHelperApp”’, then the code will not execute unless the app is
> present — there’s a precompilation step where, presumably, AppleScript
> determines that the target application supports the listed commands.

I see. I agree this should be removed.

Org maintainers: can I apply this patch?

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: PATCH: org-mac-link.el: Don't fail on machines without Growl installed
  2014-09-25  6:17         ` Alan Schmitt
@ 2014-10-06  6:31           ` Alan Schmitt
  2014-10-06  7:20             ` Nicolas Goaziou
  0 siblings, 1 reply; 11+ messages in thread
From: Alan Schmitt @ 2014-10-06  6:31 UTC (permalink / raw)
  To: Steve Purcell; +Cc: emacs-orgmode

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

Hello,

Unless I'm mistaken, I did not receive a reply to this question: can
I apply this patch?

I understand that Bastien is quite busy at the moment, so I'm wondering
if I should bug somebody else ;)

Best,

Alan

On 2014-09-25 08:17, Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> On 2014-09-24 20:59, Steve Purcell <steve@sanityinc.com> writes:
>
>> On 24 Sep 2014, at 20:13, Alan Schmitt <alan.schmitt@polytechnique.org> wrote:
>>
>>> tell application "System Events"
>>> 	set growlHelpers to the name of every process whose creator type contains "GRRR"
>>> 	if (count of growlHelpers) > 0 then
>>> 		set growlHelperApp to item 1 of growlHelpers
>>> 	else
>>> 		set growlHelperApp to ""
>>> 	end if
>>> end tell
>>> 
>>> I get an empty string as returned value. Is is the same for you?
>>
>>
>> Yes, that part works fine on its own even on my machine. But when the
>> code passed to AppleScript includes 'tell application
>> “GrowlHelperApp”’, then the code will not execute unless the app is
>> present — there’s a precompilation step where, presumably, AppleScript
>> determines that the target application supports the listed commands.
>
> I see. I agree this should be removed.
>
> Org maintainers: can I apply this patch?
>
> Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: PATCH: org-mac-link.el: Don't fail on machines without Growl installed
  2014-10-06  6:31           ` Alan Schmitt
@ 2014-10-06  7:20             ` Nicolas Goaziou
  2014-10-11 13:21               ` Bastien
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Goaziou @ 2014-10-06  7:20 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: Steve Purcell, emacs-orgmode

Hello,

Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> Unless I'm mistaken, I did not receive a reply to this question: can
> I apply this patch?
>
> I understand that Bastien is quite busy at the moment, so I'm wondering
> if I should bug somebody else ;)

Please go ahead (applying the patch, not bugging somebody!).


Regards,

-- 
Nicolas Goaziou

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

* Re: PATCH: org-mac-link.el: Don't fail on machines without Growl installed
  2014-09-24 11:12 PATCH: org-mac-link.el: Don't fail on machines without Growl installed Steve Purcell
  2014-09-24 15:38 ` Alan Schmitt
@ 2014-10-09 11:40 ` Alan Schmitt
  2014-10-09 12:11   ` Steve Purcell
  1 sibling, 1 reply; 11+ messages in thread
From: Alan Schmitt @ 2014-10-09 11:40 UTC (permalink / raw)
  To: Steve Purcell; +Cc: emacs-orgmode

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

On 2014-09-24 12:12, Steve Purcell <steve@sanityinc.com> writes:

> The existing Applescript for grabbing flagged mail messages can only work on machines which have Growl installed. This is increasingly rarely the case as Growl has been obsoleted by OS X’s own notification system.

Applied. Thank you for the patch and sorry for the delay.

Alan

-- 
OpenPGP Key ID : 040D0A3B4ED2E5C7

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]

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

* Re: PATCH: org-mac-link.el: Don't fail on machines without Growl installed
  2014-10-09 11:40 ` Alan Schmitt
@ 2014-10-09 12:11   ` Steve Purcell
  0 siblings, 0 replies; 11+ messages in thread
From: Steve Purcell @ 2014-10-09 12:11 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: emacs-orgmode

On 9 Oct 2014, at 12:40, Alan Schmitt <alan.schmitt@polytechnique.org> wrote:

> 
> Applied. Thank you for the patch and sorry for the delay.
> 


Thanks for merging both of those patches. I’ll re-work the other one (re. broken “message:” links) in the near future and resubmit.

-Steve

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

* Re: PATCH: org-mac-link.el: Don't fail on machines without Growl installed
  2014-10-06  7:20             ` Nicolas Goaziou
@ 2014-10-11 13:21               ` Bastien
  0 siblings, 0 replies; 11+ messages in thread
From: Bastien @ 2014-10-11 13:21 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Steve Purcell, Alan Schmitt, emacs-orgmode

Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Please go ahead (applying the patch, not bugging somebody!).

Alan, from now on, you can use this as a general rule :)

Thanks!

-- 
 Bastien

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

end of thread, other threads:[~2014-10-11 13:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-24 11:12 PATCH: org-mac-link.el: Don't fail on machines without Growl installed Steve Purcell
2014-09-24 15:38 ` Alan Schmitt
2014-09-24 15:35   ` Steve Purcell
2014-09-24 19:13     ` Alan Schmitt
2014-09-24 19:59       ` Steve Purcell
2014-09-25  6:17         ` Alan Schmitt
2014-10-06  6:31           ` Alan Schmitt
2014-10-06  7:20             ` Nicolas Goaziou
2014-10-11 13:21               ` Bastien
2014-10-09 11:40 ` Alan Schmitt
2014-10-09 12:11   ` Steve Purcell

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