Home Download Buy Blog Forum Support

Favorite Files

Re: Favorite Files

Postby phillip.koebbe on Wed Mar 21, 2012 1:26 pm

Hey facelessuser,

Thanks for all you're doing, not only on this plugin, but for the ST2 community at large. Very much appreciated!

Sorry to inform you, though, that the groups functionality doesn't seem to be working. I created 4 four files and saved them to the filesystem (though I did leave them blank), and then tried to add them to a favorites group. They didn't get added, but the favorites group name did get saved (somewhere) because it was available to me during later attempts at saving the files to a group. I also added a little content to each file and tried again, but with the same results.

And I did restart ST2 at some point after installing the plugin. It may have been after the first attempt at saving a group, though. I can't remember.

I doubt that it will be very helpful, but I recorded a short screencast [1] illustrating the process. In the video, I mention that I didn't see a settings file of any kind in the project directory (though I'm not sure why I expected one there), but I did see the favorite_files_list.json in Packages/User, but it was empty except for what appears to be default content:

Code: Select all
{
    "files": {},
    "groups": {},
    "version": 1
}


When you save a group of files, are you making any attempt at storing the view indexes? It would be nice if the files were opened in the same order they were in when the favorite group was saved.

[1] http://www.youtube.com/watch?v=1NZMWm_uCfM
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: Favorite Files

Postby facelessuser on Wed Mar 21, 2012 1:51 pm

phillip.koebbe wrote:Sorry to inform you, though, that the groups functionality doesn't seem to be working


Whoops! I switched from using a dictionary to a list but forgot two lines of code that is still trying to access a dictionary. Update your branch and delete the old list file.

phillip.koebbe wrote:When you save a group of files, are you making any attempt at storing the view indexes? It would be nice if the files were opened in the same order they were in when the favorite group was saved.


I allow you to save all views in a group or all views in a window. I would have a difficult time predicting your layout setup (I might just ignore layouts). And I would have to switch back yet again to using dictionaries. Let me make sure groups is working in general, then I will evaluate this request. Oh, also you can append to a group, so view index would mean less and less as you add more.

I currently sort the json, so I could probably stop that, that would at least leave the files in the order they were saved (group 0 -> last group and view 0 -> last view).
Last edited by facelessuser on Wed Mar 21, 2012 2:10 pm, edited 4 times in total.
facelessuser
 
Posts: 1448
Joined: Tue Apr 05, 2011 7:38 pm

Re: Favorite Files

Postby facelessuser on Wed Mar 21, 2012 1:54 pm

Just confirmed now working :)

Screen Shot 2012-03-21 at 7.49.14 AM.png
Screen Shot 2012-03-21 at 7.49.14 AM.png (56.84 KiB) Viewed 1869 times
facelessuser
 
Posts: 1448
Joined: Tue Apr 05, 2011 7:38 pm

Re: Favorite Files

Postby phillip.koebbe on Wed Mar 21, 2012 9:51 pm

facelessuser wrote:Whoops! I switched from using a dictionary to a list but forgot two lines of code that is still trying to access a dictionary. Update your branch and delete the old list file.


I've wondered a few times if it would somehow be possible to TDD one of these plugins...

facelessuser wrote:
phillip.koebbe wrote:When you save a group of files, are you making any attempt at storing the view indexes? It would be nice if the files were opened in the same order they were in when the favorite group was saved.


I allow you to save all views in a group or all views in a window. I would have a difficult time predicting your layout setup (I might just ignore layouts). And I would have to switch back yet again to using dictionaries. Let me make sure groups is working in general, then I will evaluate this request. Oh, also you can append to a group, so view index would mean less and less as you add more.

I currently sort the json, so I could probably stop that, that would at least leave the files in the order they were saved (group 0 -> last group and view 0 -> last view).


I certainly don't want to seem too demanding. And I understand what you're saying about the difficulty in knowing layout and adding files to the group. Let me use the current feature set for a while and see how it goes. If it seems like not having them restored in a particular order is causing me too much pain, I'll have a go at implementing that myself. If you weren't so blasted fast, I was going to have a go at this plugin myself anyway. :)

One thing you could do is store them in the order they are initially in, then append new files to the end. If you reopen them in that same order, that would suffice. Is it possible to overwrite an existing group definition? If so, I could just overwrite it when I rearrange my files. Seems like that might be a decent win-win: I (and people like me) get the ability to reopen files in something like the order they were in when last opened, and you don't have to worry about recording specific groups/indexes from ST2.

[Later ... ]

Okay, during the forum's downtime, I experimented a bit with the new code. It appears that when I save a group of files to an existing group, any files that aren't already in the group are appended to the list. If there was an option to completely overwrite the list so it would get redefined, I'd be content with not having a specific piece of "ensure order on reopen" functionality. Oh, and an option to suppress the "6 files already in the group" message.

Very nice work, facelessuser. I'm going to have to pull myself away from the other things I'm doing and study your code. I'm sure I'll learn something.
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: Favorite Files

Postby facelessuser on Wed Mar 21, 2012 10:03 pm

phillip.koebbe wrote:I certainly don't want to seem too demanding. And I understand what you're saying about the difficulty in knowing layout and adding files to the group. Let me use the current feature set for a while and see how it goes. If it seems like not having them restored in a particular order is causing me too much pain, I'll have a go at implementing that myself. If you weren't so blasted fast, I was going to have a go at this plugin myself anyway. :)


No biggie, I've just been overhauling a lot of stuff. Originally it was going to be super simple, but the suggestions you have made are great, but they required re-architecting the code. I may add these in once I get the basics ironed out; I still have per project support, and that seems like a bigger pain. From what I can tell, I would have to search the session to find the project file for the window I am in, and then parse the project file to find its root...then I can finally add per project favorites. I am going to play with it though. I kind of wish this was exposed in the API...who knows maybe it is and I just don't know it yet.

phillip.koebbe wrote:One thing you could do is store them in the order they are initially in, then append new files to the end. If you reopen them in that same order, that would suffice. Is it possible to overwrite an existing group definition? If so, I could just overwrite it when I rearrange my files. Seems like that might be a decent win-win: I (and people like me) get the ability to reopen files in something like the order they were in when last opened, and you don't have to worry about recording specific groups/indexes from ST2.


That is what I meant by not sorting the JSON file. Currently when I store the paths, they are ordered because they are in a list, but then I sort the JSON and muck up the order. If I stop sorting it, they should remain in the order I add them, and I add them in the order ST2 gives them to me. I believe it gets them in tab order. And then new files get appended. I will look into an option for complete overwrite. I and I will look into a silent option for info dialogs and only show more critical dialogs.

phillip.koebbe wrote:Very nice work, facelessuser. I'm going to have to pull myself away from the other things I'm doing and study your code. I'm sure I'll learn something.

Very kind words. Thanks! :D
facelessuser
 
Posts: 1448
Joined: Tue Apr 05, 2011 7:38 pm

Re: Favorite Files

Postby facelessuser on Thu Mar 22, 2012 2:41 am

New version

Version 0.3.0
- Ensure favorites are opened in order they were saved
- Add option to replace group
- Remove dialogs alerting user that files already existed in favorites

This should give it a more reasonable feel.

Projects is next, but not tonight. I think I am going to require the user to add something to their per project settings to enable per project favorites; makes it much nice and easy to implement.
facelessuser
 
Posts: 1448
Joined: Tue Apr 05, 2011 7:38 pm

Re: Favorite Files

Postby phillip.koebbe on Thu Mar 22, 2012 3:45 pm

facelessuser wrote:New version

Version 0.3.0
- Ensure favorites are opened in order they were saved
- Add option to replace group
- Remove dialogs alerting user that files already existed in favorites

This should give it a more reasonable feel.

Projects is next, but not tonight. I think I am going to require the user to add something to their per project settings to enable per project favorites; makes it much nice and easy to implement.


Haven't exercised it a great deal yet, but what I've seen so far works as I'd expect it to. Looking forward to the project-specific stuff. Keep it coming!
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: Favorite Files

Postby facelessuser on Thu Mar 22, 2012 3:51 pm

Version 0.3.1
-Open files in active group

Seems like this wasn't working on the last version, should work now.

Still rolling project specific ideas around. Would be a lot easier if certain settings were available from a window object. So far the ideas I have been rolling around seem to involve hunting through the session to find the windows project..ugh (seems like unneeded work and overhead). Or leaving some kind of variable in the projects's settings section, but that is only accessible through a view, so if a view isn't open...

It would be nice if the window object just had a project method like window.project() and it would just give you the path to the project file or None if it did not exist.

Oh well, I will keep giving it some thought.
facelessuser
 
Posts: 1448
Joined: Tue Apr 05, 2011 7:38 pm

Re: Favorite Files

Postby phillip.koebbe on Thu Mar 22, 2012 5:25 pm

This probably isn't a much better solution, but it is a possibility:

You could use sublime.active_window().folders() and look for *.sublime-project. In many cases, there will be only one folder as folders() appears to return only the root. I'm sure there are many people who will have additional folders added to the project, but I can't imagine there would be so many that it would be noticeable looking for a single file. If you happen to find more than one project file (which would surprise me), you could pop up something and ask the user which one is correct. Gets a little clunky in that case, but again, I seriously doubt you will encounter too many cases where there are multiple project files. Seems like ST2 would have a problem with that anyway.
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: Favorite Files

Postby facelessuser on Fri Mar 23, 2012 1:33 am

phillip.koebbe wrote:This probably isn't a much better solution, but it is a possibility:

You could use sublime.active_window().folders() and look for *.sublime-project. In many cases, there will be only one folder as folders() appears to return only the root. I'm sure there are many people who will have additional folders added to the project, but I can't imagine there would be so many that it would be noticeable looking for a single file. If you happen to find more than one project file (which would surprise me), you could pop up something and ask the user which one is correct. Gets a little clunky in that case, but again, I seriously doubt you will encounter too many cases where there are multiple project files. Seems like ST2 would have a problem with that anyway.


I will consider it. There are a number of things I am trying to figure out. Do I present both global favorites and project favorites, or do I require the user to switch between them (like a toggle setting). I prefer to not have to ask each time for project favorites or global because that would probably get old. I also need an elegant way to switch between windows and switch project preferences or switch to global if there aren't any. I will figure something out. After I get projects working I think I will submit it to Package Control.

The good news is, the generally functionality feels pretty good now. I just want to get the project part in without making it feel clunky.
facelessuser
 
Posts: 1448
Joined: Tue Apr 05, 2011 7:38 pm

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 4 guests