Skip to content

Commit

Permalink
Add Open Note note_guid from clipboard or prompt, handling links too (
Browse files Browse the repository at this point in the history
  • Loading branch information
bordaigorl committed Jun 12, 2016
1 parent b839f7c commit 7c2c4f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{ "command": "view_in_evernote_client", "caption": "Evernote: View Note in Evernote client" },
{ "command": "open_evernote_note", "args": {"by_searching": true}, "caption": "Evernote: Search Note" },
{ "command": "open_evernote_note", "args": {"max_notes": 10, "by_searching": "*", "order": "updated", "ascending": false}, "caption": "Evernote: List recent notes" },
{ "command": "open_evernote_note", "args": {"note_guid": "prompt"}, "caption": "Evernote: Open Note From Link or ID..." },
{ "command": "attach_to_evernote_note", "caption": "Evernote: Attach current file to a note" },
{ "command": "insert_link_to_evernote_note", "caption": "Evernote: Insert link to a note (browse)" },
{ "command": "insert_link_to_evernote_note", "args": {"by_searching": true}, "caption": "Evernote: Insert link to a note (search)" },
Expand Down
10 changes: 10 additions & 0 deletions sublime_evernote.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,12 @@ def do_search(query):
async_do(lambda: notes_panel(self.find_notes(search_args, max_notes), True), "Fetching notes list", done_msg=None)

if note_guid:
if note_guid == "prompt":
self.window.show_input_panel("Note GUID or link:", "", lambda x: self.open_note(x, **kwargs), None, None)
return
elif note_guid == "clipboard":
note_guid = sublime.get_clipboard(2000)

self.open_note(note_guid, **kwargs)
return

Expand Down Expand Up @@ -850,6 +856,10 @@ def find_notes(self, search_args, max_notes=None):
NoteStore.NotesMetadataResultSpec(includeTitle=True, includeNotebookGuid=True)).notes

def open_note(self, guid, convert=True, **unk_args):
try:
guid = guid.strip().split('/')[-1]
except Exception:
pass
async_do(lambda: self.do_open_note(guid, convert, **unk_args), "Retrieving note")

def do_open_note(self, guid, convert=True, **unk_args):
Expand Down

0 comments on commit 7c2c4f5

Please sign in to comment.