Skip to content

Commit

Permalink
Add support simplenote file syntax for opening the note
Browse files Browse the repository at this point in the history
  • Loading branch information
haydnhkim committed Nov 21, 2015
1 parent e2fa93b commit 0a4ff2e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
17 changes: 12 additions & 5 deletions quick_simplenote.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_note_from_path(view_filepath):
if note:
note = note[0]


return note

def get_note_name(note):
Expand Down Expand Up @@ -294,6 +294,13 @@ def flush_saves():
HandleNoteViewCommand.waiting_to_save.append(new_entry)
sublime.set_timeout(flush_saves, debounce_time)

def on_load(self, view):
view_filepath = view.file_name()
note = get_note_from_path(view_filepath)
syntax = settings.get('note_syntax')
if note and syntax:
view.set_syntax_file(syntax)

def get_current_content(self, view):
note_file_content = ""
try:
Expand Down Expand Up @@ -433,7 +440,7 @@ def notes_synch(self, notes):
for view in view_list:
if view.file_name() == None:
continue

if view.is_dirty():
open_files_dirty.append(path.split(view.file_name())[1])
else:
Expand All @@ -447,13 +454,13 @@ def notes_synch(self, notes):

if not note['needs_update']:
continue

try:
filename = note['filename']
except KeyError as e:
others.append(note)
continue

if filename in open_files_dirty:
lu.append(note)
elif filename in open_files_ok:
Expand Down Expand Up @@ -637,4 +644,4 @@ def reload_if_needed():
settings.add_on_change('username', reload_if_needed)
settings.add_on_change('password', reload_if_needed)

reload_if_needed()
reload_if_needed()
11 changes: 9 additions & 2 deletions quick_simplenote.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"username": ""
,"password": ""
// --------------------------------
// Simplenote Synctax setting:
// (If you are using MarkdownEditing, try
// "note_syntax": "Packages/MarkdownEditing/Markdown.tmLanguage"
// )
// --------------------------------
,"note_syntax": ""
// --------------------------------
// Sync settings:
// --------------------------------
// Sync when sublime text starts:
Expand Down Expand Up @@ -32,5 +39,5 @@
// "title_regex": "\\[ST\\]",
// "extension": "todo"
// }]
}

}

0 comments on commit 0a4ff2e

Please sign in to comment.