emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Steve Purcell <steve@sanityinc.com>
To: emacs-orgmode@gnu.org
Subject: PATCH: org-mac-link.el: Don't fail on machines without Growl installed
Date: Wed, 24 Sep 2014 12:12:31 +0100	[thread overview]
Message-ID: <7B9D9129-4BEC-42F3-851D-00D4D2A43A8A@sanityinc.com> (raw)

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


             reply	other threads:[~2014-09-24 11:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-24 11:12 Steve Purcell [this message]
2014-09-24 15:38 ` PATCH: org-mac-link.el: Don't fail on machines without Growl installed 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7B9D9129-4BEC-42F3-851D-00D4D2A43A8A@sanityinc.com \
    --to=steve@sanityinc.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).