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

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