* [PATCH] Add Support for Evernote in Org-Mac Link
@ 2015-12-14 18:08 Mike McLean
2015-12-15 13:32 ` Alan Schmitt
2015-12-18 10:30 ` Alan Schmitt
0 siblings, 2 replies; 3+ messages in thread
From: Mike McLean @ 2015-12-14 18:08 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 617 bytes --]
The attached patch adds support for Evernote Note links in
contrib/org-mac-link.el
Commit Message:
org-mac-link.el: Add support for Evernote Note Links
(org-mac-grab-Evernote-app-p, org-mac-evernote-path): New custom
variables to control Evernote grabbing
(org-mac-evernote-note-open): New function to open an Evernote note by
ID
(org-as-get-selected-evernote-notes,
org-mac-evernote-note-insert-selected): New functions to get the
selected Evernote note(s) and insert them into current buffer
Note this change also defines a new link type ("mac-evernote") via a
call to “org-add-link-type”.
[-- Attachment #1.2: Type: text/html, Size: 824 bytes --]
[-- Attachment #2: 0001-org-mac-link.el-Add-support-for-Evernote-Note-Links.patch --]
[-- Type: application/octet-stream, Size: 5646 bytes --]
From 48c7da6fd8e692c271c27f9ade2c7c6c32466ada Mon Sep 17 00:00:00 2001
From: Mike McLean <mike.mclean@pobox.com>
Date: Mon, 14 Dec 2015 12:55:25 -0500
Subject: [PATCH] org-mac-link.el: Add support for Evernote Note Links
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
(org-mac-grab-Evernote-app-p, org-mac-evernote-path): New custom
variables to control Evernote grabbing
(org-mac-evernote-note-open): New function to open an Evernote note by
ID
(org-as-get-selected-evernote-notes,
org-mac-evernote-note-insert-selected): New functions to get the
selected Evernote note(s) and insert them into current buffer
Note this change also defines a new link type ("mac-evernote") via a
call to “org-add-link-type”.
---
contrib/lisp/org-mac-link.el | 72 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index e04fb80..5870b73 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -26,6 +26,10 @@
;; Author: Mike McLean <mike.mclean@pobox.com>
;; Make the path to Microsoft Outlook a `defcustom'
;;
+;; Version 1.5
+;; Author: Mike McLean <mike.mclean@pobox.com>
+;; Add Support for Evernote
+;;
;; This file is not part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or modify
@@ -66,6 +70,7 @@
;; Skim.app - Grab a link to the selected page in the topmost pdf document
;; Microsoft Outlook.app - Grab a link to the selected message in the message list
;; DEVONthink Pro Office.app - Grab a link to the selected DEVONthink item(s); open DEVONthink item by reference
+;; Evernote.app - Grab a link to the selected Evernote item(s); open Evernote item by ID
;;
;;
;; Installation:
@@ -195,6 +200,23 @@
:group 'org-mac-flagged-mail
:type 'string)
+(defcustom org-mac-grab-Evernote-app-p
+ (< 0 (length (shell-command-to-string
+ "mdfind kMDItemCFBundleIdentifier == 'com.evernote.Evernote'")))
+ "Add menu option [e]vernote to grab note links from Evernote.app."
+ :tag "Grab Evernote.app note links"
+ :group 'org-mac-link
+ :type 'boolean)
+
+(defcustom org-mac-evernote-path (replace-regexp-in-string (rx (* (any " \t\n")) eos)
+ ""
+ (shell-command-to-string
+ "mdfind kMDItemCFBundleIdentifier == 'com.evernote.Evernote'"))
+ "The path to the installed copy of Evernote.app. Do not escape spaces as the AppleScript call will quote this string."
+ :tag "Path to Evernote"
+ :group 'org-mac-link
+ :type 'string)
+
\f
;; In mac.c, removed in Emacs 23.
(declare-function do-applescript "org-mac-message" (script))
@@ -226,6 +248,7 @@ When done, go grab the link, and insert it at point."
("f" "irefox" org-mac-firefox-insert-frontmost-url ,org-mac-grab-Firefox-app-p)
("v" "imperator" org-mac-vimperator-insert-frontmost-url ,org-mac-grab-Firefox+Vimperator-p)
("c" "hrome" org-mac-chrome-insert-frontmost-url ,org-mac-grab-Chrome-app-p)
+ ("e" "evernote" org-mac-evernote-note-insert-selected ,org-mac-grab-Evernote-app-p)
("t" "ogether" org-mac-together-insert-selected ,org-mac-grab-Together-app-p)
("S" "kim" org-mac-skim-insert-page ,org-mac-grab-Skim-app-p)
("A" "crobat" org-mac-acrobat-insert-page ,org-mac-grab-Acrobat-app-p)))
@@ -720,6 +743,55 @@ after heading."
(insert "\n")
(org-insert-heading nil t)
(insert org-heading "\n" (org-mac-outlook-message-get-links "f"))))))
+\f
+;; Handle links from Evernote.app
+
+(org-add-link-type "mac-evernote" 'org-mac-evernote-note-open)
+
+(defun org-mac-evernote-note-open (noteid)
+ "Open a note in Evernote"
+ (do-applescript
+ (concat
+ "tell application \"" org-mac-evernote-path "\"\n"
+ " set theNotes to get every note of every notebook where its local id is \"" (substring-no-properties noteid) "\"\n"
+ " repeat with _note in theNotes\n"
+ " if length of _note is not 0 then\n"
+ " set _selectedNote to _note\n"
+ " end if\n"
+ " end repeat\n"
+ " open note window with item 1 of _selectedNote\n"
+ " activate\n"
+ "end tell")))
+
+(defun org-as-get-selected-evernote-notes ()
+ "AppleScript to create links to selected notes in Evernote.app."
+ (do-applescript
+ (concat
+ "tell application \"" org-mac-evernote-path "\"\n"
+ " set noteCount to count selection\n"
+ " if (noteCount < 1) then\n"
+ " return\n"
+ " end if\n"
+ " set theLinkList to {}\n"
+ " set theSelection to selection\n"
+ " repeat with theNote in theSelection\n"
+ " set theTitle to title of theNote\n"
+ " set theID to local id of theNote\n"
+ " set theURL to \"mac-evernote:\" & theID\n"
+ " set theLink to theURL & \"::split::\" & theTitle & \"\n\"\n"
+ " copy theLink to end of theLinkList\n"
+ " end repeat\n"
+ " return theLinkList as string\n"
+ "end tell\n")))
+
+(defun org-mac-evernote-note-insert-selected ()
+ "Insert a link to the notes currently selected in Evernote.app.
+This will use AppleScript to get the note id and the title of the
+note(s) in Evernote.app and make a link out of it/them."
+ (interactive)
+ (message "Org Mac Evernote: searching notes...")
+(insert (org-mac-paste-applescript-links
+ (org-as-get-selected-evernote-notes))))
\f
;; Handle links from DEVONthink Pro Office.app
--
2.6.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Add Support for Evernote in Org-Mac Link
2015-12-14 18:08 [PATCH] Add Support for Evernote in Org-Mac Link Mike McLean
@ 2015-12-15 13:32 ` Alan Schmitt
2015-12-18 10:30 ` Alan Schmitt
1 sibling, 0 replies; 3+ messages in thread
From: Alan Schmitt @ 2015-12-15 13:32 UTC (permalink / raw)
To: Mike McLean; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 434 bytes --]
On 2015-12-14 19:08, Mike McLean <mike.mclean@pobox.com> writes:
> The attached patch adds support for Evernote Note links in
> contrib/org-mac-link.el
This looks good to me, although I don't have Evernote so I cannot test
it. I'll push it at the end of the week unless I hear otherwise.
Thanks,
Alan
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Athmospheric CO₂ (Updated December 13, 2015, Mauna Loa Obs.): 401.31 ppm
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Add Support for Evernote in Org-Mac Link
2015-12-14 18:08 [PATCH] Add Support for Evernote in Org-Mac Link Mike McLean
2015-12-15 13:32 ` Alan Schmitt
@ 2015-12-18 10:30 ` Alan Schmitt
1 sibling, 0 replies; 3+ messages in thread
From: Alan Schmitt @ 2015-12-18 10:30 UTC (permalink / raw)
To: Mike McLean; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 302 bytes --]
On 2015-12-14 19:08, Mike McLean <mike.mclean@pobox.com> writes:
> The attached patch adds support for Evernote Note links in
> contrib/org-mac-link.el
Pushed, thanks.
Alan
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Athmospheric CO₂ (Updated December 13, 2015, Mauna Loa Obs.): 401.31 ppm
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-18 10:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-14 18:08 [PATCH] Add Support for Evernote in Org-Mac Link Mike McLean
2015-12-15 13:32 ` Alan Schmitt
2015-12-18 10:30 ` Alan Schmitt
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).