Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hooking up binding, closing of inactive files
- Loading branch information
1 parent
2064ed5
commit 91752cb
Showing
4 changed files
with
17 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
|
||
TidyTabs.pyc | ||
.DS_Store | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
{ | ||
"keys": ["ctrl+w"], "command": "tidy_tabs" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sss | ||
This is a tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |