emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-mac-link: Disable Evernote capture by default
@ 2021-02-17 15:53 Aaron Jensen
  2021-02-27 13:14 ` Aaron Jensen
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Jensen @ 2021-02-17 15:53 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Aaron Jensen

The two `shell-command-to-string` invocations during eval are
extremely slow. Users of Evernote should `org-mac-grab-Evernote-app-p`
and `org-mac-evernote-path` explicitly.

* contrib/lisp/org-mac-link.el (org-mac-grab-Evernote-app-p): Default
to nil
(org-mac-evernote-path): Default to nil and add a function of the same
name that will either use the variable or a shell invocation to mdfind
(org-mac-evernote-note-open): Use the function version of org-mac-evernote-path
(org-as-get-selected-evernote-notes): Use the function version of
org-mac-evernote-path
---
 contrib/lisp/org-mac-link.el | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/contrib/lisp/org-mac-link.el b/contrib/lisp/org-mac-link.el
index e56354c4f..ec004d8b9 100644
--- a/contrib/lisp/org-mac-link.el
+++ b/contrib/lisp/org-mac-link.el
@@ -207,18 +207,13 @@
   :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'")))
+(defcustom org-mac-grab-Evernote-app-p nil
   "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'"))
+(defcustom org-mac-evernote-path nil
   "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
@@ -809,11 +804,21 @@ after heading."
 
 (org-link-set-parameters "mac-evernote" :follow #'org-mac-evernote-note-open)
 
+(defun org-mac-evernote-path ()
+  "Get path to evernote.
+First consider the value of ORG-MAC-EVERNOTE-PATH, then attempt to find it.
+Finding the path can be slow."
+  (or org-mac-evernote-path
+      (replace-regexp-in-string (rx (* (any " \t\n")) eos)
+                                ""
+                                (shell-command-to-string
+                                 "mdfind kMDItemCFBundleIdentifier == 'com.evernote.Evernote'"))))
+
 (defun org-mac-evernote-note-open (noteid _)
   "Open a note in Evernote"
   (do-applescript
    (concat
-    "tell application \"" org-mac-evernote-path "\"\n"
+    "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"
@@ -828,7 +833,7 @@ after heading."
   "AppleScript to create links to selected notes in Evernote.app."
   (do-applescript
    (concat
-    "tell application \"" org-mac-evernote-path "\"\n"
+    "tell application \"" (org-mac-evernote-path) "\"\n"
      "    set noteCount to count selection\n"
      "    if (noteCount < 1) then\n"
      "        return\n"
-- 
2.28.0



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

* Re: [PATCH] org-mac-link: Disable Evernote capture by default
  2021-02-17 15:53 [PATCH] org-mac-link: Disable Evernote capture by default Aaron Jensen
@ 2021-02-27 13:14 ` Aaron Jensen
  2021-02-27 22:58   ` Kyle Meyer
  0 siblings, 1 reply; 5+ messages in thread
From: Aaron Jensen @ 2021-02-27 13:14 UTC (permalink / raw)
  To: emacs-orgmode

On Wed, Feb 17, 2021 at 9:55 AM Aaron Jensen <aaronjensen@gmail.com> wrote:
>
> The two `shell-command-to-string` invocations during eval are
> extremely slow. Users of Evernote should `org-mac-grab-Evernote-app-p`
> and `org-mac-evernote-path` explicitly.

Hi all,

Any chance of getting this merged in? It's a pretty nasty one for mac users.

Thanks,

Aaron


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

* Re: [PATCH] org-mac-link: Disable Evernote capture by default
  2021-02-27 13:14 ` Aaron Jensen
@ 2021-02-27 22:58   ` Kyle Meyer
  2021-02-28 11:11     ` Alan Schmitt
  2021-03-02  5:23     ` Kyle Meyer
  0 siblings, 2 replies; 5+ messages in thread
From: Kyle Meyer @ 2021-02-27 22:58 UTC (permalink / raw)
  To: Aaron Jensen; +Cc: Alan Schmitt, emacs-orgmode, Mike McLean

Aaron Jensen writes:

> On Wed, Feb 17, 2021 at 9:55 AM Aaron Jensen <aaronjensen@gmail.com> wrote:
>>
>> The two `shell-command-to-string` invocations during eval are
>> extremely slow. Users of Evernote should `org-mac-grab-Evernote-app-p`
>> and `org-mac-evernote-path` explicitly.
>
> Hi all,
>
> Any chance of getting this merged in? It's a pretty nasty one for mac users.

Thanks for the patch.  Ideally someone that uses macOS would provide a
review.  Based on the history of the file, I've cc'd two people that may
be willing/able to do so.

Note that the plan is to move contrib/ to a separate repo [1], with the
eventual goal of each file being maintained elsewhere, in case you or
others are interested.

  [1] https://orgmode.org/list/87wnzfy60h.fsf@bzg.fr


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

* Re: [PATCH] org-mac-link: Disable Evernote capture by default
  2021-02-27 22:58   ` Kyle Meyer
@ 2021-02-28 11:11     ` Alan Schmitt
  2021-03-02  5:23     ` Kyle Meyer
  1 sibling, 0 replies; 5+ messages in thread
From: Alan Schmitt @ 2021-02-28 11:11 UTC (permalink / raw)
  To: Kyle Meyer, Aaron Jensen; +Cc: emacs-orgmode, Mike McLean

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

On 2021-02-27 17:58, Kyle Meyer <kyle@kyleam.com> writes:

>> Any chance of getting this merged in? It's a pretty nasty one for mac users.
>
> Thanks for the patch.  Ideally someone that uses macOS would provide a
> review.  Based on the history of the file, I've cc'd two people that may
> be willing/able to do so.

Sorry, but I’ve switched to Linux a couple years ago.

Best,

Alan

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

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

* Re: [PATCH] org-mac-link: Disable Evernote capture by default
  2021-02-27 22:58   ` Kyle Meyer
  2021-02-28 11:11     ` Alan Schmitt
@ 2021-03-02  5:23     ` Kyle Meyer
  1 sibling, 0 replies; 5+ messages in thread
From: Kyle Meyer @ 2021-03-02  5:23 UTC (permalink / raw)
  To: Aaron Jensen; +Cc: emacs-orgmode

Kyle Meyer writes:

> Thanks for the patch.  Ideally someone that uses macOS would provide a
> review.  Based on the history of the file, I've cc'd two people that may
> be willing/able to do so.

Applied (afd75d05a).  Thanks again.


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

end of thread, other threads:[~2021-03-02  5:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-17 15:53 [PATCH] org-mac-link: Disable Evernote capture by default Aaron Jensen
2021-02-27 13:14 ` Aaron Jensen
2021-02-27 22:58   ` Kyle Meyer
2021-02-28 11:11     ` Alan Schmitt
2021-03-02  5:23     ` Kyle Meyer

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