sublime_text
sublime_text copied to clipboard
Automatically create "anonymous" .sublime-project files when closing a window (not already saved in a .sublime-project)
Problem description
When you open Sublime Text with subl /some/full/path/directory and you close Sublime Text without saving it in a .sublime-project file, all your workspace and the open directory itself are lost when you close the "anonymous project" window (a Sublime Text window with open directories not saved in a .sublime-project file could be called a "anonymous" project).
Preferred solution
After you open Sublime Text with subl /some/full/path/directory and you close that window without saving first a .sublime-project file, Sublime Text automatically creates an "anonymous" project in his Data/cache/anonymousprojects directory, with the base name of the first directory opened on the recent-closed window, i.e., directory.sublime-project. If the file already exists, then it includes a timestamp on the directory name. Then, this "anonymous" project (and workspace) could be reopened later on, by going to the menu Project -> Open Recent -> directory.sublime-project
Additionally, a new command should also be added, the Renamed Project File, which would change the name of the project file in the Data/cache/anonymousprojects directory or any other place the .sublime-project file is on. This command would be useful to properly name my "anonymous" projects which do no get a nice name when automatically created, i.e., directory-2019-12-15.sublime-project
Related issues
- .sublime-project file without the file name part #828
- Layout not saving on Sublime Text 3 quit #1907
Sounds like an idea for a plugin or maybe an extension for @ranky3k's ProjectManager.
A plugin an query window.project_file_name() and the window.project_data() with the folders being added. An EventListener could be used to check those and automatically save an auto-generated project. As the save_project_as doesn't take a file argument to silently save the project, you'd probably need to manually encode and write the JSON data.
A normal quick panel or better a command with InputHandler could be used to open the most recent auto-generated projects.
This might be one of possible implementations of the following feature request: https://forum.sublimetext.com/t/open-recent-reopen-closed-window/37802
This would really be helpful if implemented. Like, when we close an anonymous file, we always get prompted whether to save it or not. With an anonymous project, it should act the same.
FYI just found this plugin which is almost what is being discussed here - though still not the most invisible solution.
https://github.com/jmooney/EasyWorkspace-sublime