-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathautosave.py
executable file
·27 lines (21 loc) · 1.03 KB
/
autosave.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import sublime
import sublime_plugin
class AutomaticSaveCommand(sublime_plugin.EventListener):
clicks = 0
def save_me(self, view):
if view.settings().get('syntax') == 'Packages/Fountainhead/Fountainhead.tmLanguage':
# if 'Fountainhead.tmLanguage' in view.settings().get('syntax'):
# if sublime.load_settings('Fountainhead.sublime-settings').get('auto_save', True):
if view.settings().get('auto_save', True):
# self.clicksTrigger = sublime.load_settings('Fountainhead.sublime-settings').get('auto_save_count', 42)
self.clicksTrigger = view.settings().get('auto_save_count', 42)
self.clicks += 1
if self.clicks >= self.clicksTrigger:
self.clicks = 0
view.run_command('save')
def on_modified(self, view):
if int(sublime.version()) < 3000:
self.save_me(view)
def on_modified_async(self, view):
if int(sublime.version()) >= 3000:
self.save_me(view)