zomg, Evernote and Emacs

Posted: - Modified: | emacs

Update 2013-10-19: Check out https://github.com/pymander/evernote-mode for a possibly better way to do things. =)

This is totally raw and needs a lot of hacking, but look, I can dump subtrees from my Org notes into Evernote using Emacs Evernote Mode. The desktop app handles these perfectly, although the Android app does funny things to the whitespace if you edit the note. Still, great as a reference!

Mwahahahaha!

(defun sacha/org-get-subtree-region ()
  "Return the start and end of the current subtree."
  (save-excursion
    (let (beg end folded (beg0 (point)))
      (if (org-called-interactively-p 'any)
          (org-back-to-heading nil) ; take what looks like a subtree
        (org-back-to-heading t)) ; take what is really there
      (org-back-over-empty-lines)
      (setq beg (point))
      (skip-chars-forward " \t\r\n")
      (save-match-data
        (save-excursion (outline-end-of-heading)
                        (setq folded (outline-invisible-p)))
        (condition-case nil
            (org-forward-same-level (1- n) t)
          (error nil))
        (org-end-of-subtree t t))
      (org-back-over-empty-lines)
      (setq end (point))
      (list beg end))))

(defun sacha/org-post-subtree-to-evernote (&optional notebook)
  "Post the current subtree to Evernote."
  (interactive)
  (let ((title (nth 4 (org-heading-components)))
        (body (apply 'buffer-substring-no-properties (sacha/org-get-subtree-region))))
    (with-temp-buffer
      (insert body)
      (enh-command-with-auth
       (let (note-attr)
         (setq note-attr
               (enh-command-create-note (current-buffer)
                                        title
                                        notebook
                                        nil "TEXT"))
         (enh-update-note-and-new-tag-attrs note-attr))))))       

In other news, I now have book notes from 156 books in my Evernote notebook. Mwahahaha! Time to add more.

You can view 29 comments or e-mail me at sacha@sachachua.com.

29 comments

Awesome! I thought I was the only person using evernote-mode. I have it working well under Linux, but not under Cygwin. Any suggestions?

I got mine to work under Cygwin after following the notes in the config. I also edited the .rb script to make it go to the http address instead of https, as my Ruby doesn't seem to have SSL support and I haven't gotten around to fixing it yet. Hope that helps!

Matthew Darling

2012-08-02T17:06:54Z

Do you suppose the generated HTML files would be compatible with OneNote's import? A combined mode that works with both services (through SkyDrive for OneNote) would be awesome!

Dave Abrahams

2012-08-17T19:26:51Z

Sacha, I've been wondering what made you pick up Evernote, and how do you use it? Doesn't having some stuff in Org and other things in Evernote just lead to information fragmentation?

Thanks

Dave: I mostly use Evernote for the ability to search within hand-written images, which I use for my sketchnotes. I'm also curious about the ability to easily take image and sound notes. So far, no problems with information fragmentation, even between Org and my blog and Evernote. =) I'll probably run into that someday, but in the meantime, not stressing out about it - just keeping redundant copies of things that are particularly important to me. <laugh></laugh>

Jason John Wells

2012-10-03T08:39:06Z

Hi Sacha and/or Fellow Commentator,

I would LOVE to link up Emacs and Evernote but I also ran into a

'SSL_connect SYSCALL returned=5 errno= sate=unknown state'

Is that the same error you fixed in enclient.rb?

I tried deleting the the 's' off 'https' but still get that error. This is my first time trying to edit a Ruby file so any advice is much appreciated.

Org mode is my text tool of choice and Evernote is the killer Android app for me as I live in a small Japanese town with limited Japanese ability.

Thanks for an awesome blog.

Could you try installing Cygwin and then installing ruby inside Cygwin? Maybe that makes a difference.

Been thinking about using Emacs and Evernote together, Sacha! XD This is something I realized I could do.

Happy to help you get going with it! =D

sacha. tried evernote-mode but got stuck. I tried to open a note, but after entering my pw a message reads 'can't convert nil into string' any hints?

I have the same issue -- was this ever fixed for you?

Evernote currently doesn't support out-of-band authentication for OAUTH, so I think that means Evernote integration for Emacs is broken.

ps. I'm using GNU Emacs 24.1.1 (i686-redhat-linux-gnu, GTK+ Version 2.24.13)
of 2012-10-22 on buildvm-17.phx2.fedoraproje...

Could you M-x toggle-debug-on-error and e-mail me (or better yet, the evernote-mode maintainer) your backtrace?

Debug on Error enabled globally
Waiting for the result... [2 times]
can't convert nil into String

#now using debugger (GBD)
Waiting for the result...
Blocking call to accept-process-output with quit inhibited!!
can't convert nil into String
# this is the backltrace buffer (but I think it's not evernote-mode related)
Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
gdb-show-stop-p()
(or (not (memq gud-minor-mode (quote (gdbmi pdb)))) (gdb-show-stop-p))

this is all I can get. sorry but don't know how to get more backtrace

That sounds more like the Evernote command-line tool bundled with evernote-mode isn't working for you. Could you ask Yusuke Kawakami, who wrote evernote-mode? https://github.com/rubbish/... might be another variant to try. Note that you'll need to have Ruby set up on your system.

Geoffrey Roman

2013-01-29T09:53:18Z

Hi Sacha! I'm new to Emacs and I was excited by this evernote-mode. But evernote switched to Oauth authentification and the mode. Have you got some news about this?

Also I like Evernote for its search capabilities, like PDF or images OCR searches. I'm in school so I have a lot of documents and switch just to Org-mode isn't possible. Maybe you've got some tips to get organized with all these documents easily!

Sorry about my english, I'm French...

I'm looking forward to digging into this in February. :) Hope we can figure things out!

Geoffrey Roman

2013-02-01T09:40:08Z

Thanks a lot! :)

:)

It turns out that Evernote doesn't support out-of-band authentication yet (http://discussion.evernote...., so we're out of luck for now. =|

Does that mean the evernote-mode can not be used at all if Evernote always doesn't support out-of band authentication?

I just spent some time trying to get evernote-mode working in my Emacs install. I believe some semi-substantial work will need to be done to it to work with the new authentication system. Right now it seems to be set up to log in as an API consumer, and that process is onerous (you have to get an API key, and then request that Evernote make it live on the production site. Even then, who knows if it will actually work).

C'est la vie. =( Even as an API consumer, it still won't work because Evernote doesn't currently support out-of-band authentication.

is it the same problem for nixnote? I wonder if this would work as an indirect access to evernote.

Sacha -
I have found more immediately useful stuff related to emacs org mode at your site than anywhere else<sup>[1]</sup>, so thanks! Now that it looks as if Evernote will be a preferred format by my co-workers, I want to get evernote-mode working on Windows and Linux boxen. May I complain here about my bafflement when I get stuck?

<sup>[1]</sup> Bernt Hansen's place is close.

Aww, thanks! Yes, you may, although it won't be any use until Evernote supports out-of-band authentication. =( Or someone makes a web-based service that takes an Org file and Does Stuff To It...

Erik L. Arneson

2014-11-25T21:52:32Z

Hi Sacha,
Thanks for the link to my Github project page! A few of us are still working on evernote-mode and it's kind of getting better. It uses OAuth now, and I've been fiddling with the org-mode integration.
-Erik

Awesome, thanks for working on it! =D