Skip to content

Commit

Permalink
Hooking up binding, closing of inactive files
Browse files Browse the repository at this point in the history
  • Loading branch information
bradleyboy committed Mar 9, 2012
1 parent 2064ed5 commit 91752cb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .gitignore
@@ -1,2 +1,2 @@

TidyTabs.pyc
.DS_Store
*.pyc
5 changes: 5 additions & 0 deletions Default (OSX).sublime-keymap
@@ -0,0 +1,5 @@
[
{
"keys": ["ctrl+w"], "command": "tidy_tabs"
}
]
2 changes: 1 addition & 1 deletion README.md
@@ -1 +1 @@
sss
This is a tests
25 changes: 9 additions & 16 deletions TidyTabs.py
@@ -1,31 +1,24 @@
import sublime_plugin
import sublime
import os
import time

win = sublime.Window


def scan_files():
print sublime.Window.views().length


class TidyTabsCommand(sublime_plugin.WindowCommand):

def run(self):
now = time.time()

for file in self.window.views():
mtime = os.path.getmtime(file.file_name())
atime = os.path.getatime(file.file_name())
group = self.window.get_view_index(file)[0]

# Do not close the current file of any group
if file.file_name() == self.window.active_view_in_group(group).file_name():
print file.window()
continue

print now - mtime

if now - mtime > 5 and not file.is_dirty():
print file.window()
# file.window().run_command('close')
# global win
# win = self
# sublime.set_timeout(scan_files, 1000)
# If file is not dirty and has not been modified in one hour
# and also has not been accessed in the last minute, close it.
if now - mtime > 3600 and now - atime > 60 and not file.is_dirty():
self.window.focus_view(file)
self.window.run_command('close_file')

0 comments on commit 91752cb

Please sign in to comment.