Public snipts » gregnewman's snipts » Send Safari Url to Emacs Org Mode
-
tell application "Safari" set itemTitle to do JavaScript "document.title" in front document set theURL to URL of front document end tell -- show a prompt for a link title display dialog "Enter a title:" default answer theURL set dialogInfo to result set selectedButton to button returned of dialogInfo get selectedButton set theText to text returned of dialogInfo -- setup the link text for org mode set dat to (current date) as text set crlf to (ASCII character 13) & (ASCII character 10) set theAppend to crlf & "*** [[" & theURL & "][" & theText & "]] " & dat -- setup the path and save the string to the end of the file set theFilePath to "Macintosh HD:Users:greg:gtd:" & "greg.org" as string set open_file to open for access theFilePath with write permission write theAppend to open_file starting at eof close access open_file -- have growl tell you that it worked tell application "GrowlHelperApp" set the allNotificationsList to {"Success Notification"} set the enabledNotificationsList to {"Success Notification"} register as application ¬ "Safari to Emacs Org Mode Script" all notifications allNotificationsList ¬ default notifications enabledNotificationsList ¬ icon of application "Safari" notify with name ¬ "Success Notification" title ¬ "Import Success" description "Successfully imported \"" & itemTitle & ¬ "\" to Emacs" application name "Safari to Emacs Org Mode Script" end tell



0 Comments