Home Download Buy Blog Forum Support

How to add folder to project use run_command

How to add folder to project use run_command

Postby hellojinjie on Fri Jul 05, 2013 5:54 am

I know that we can remove a folder from a project using:

Code: Select all
window.run_command('remove_folder', {'dirs': ['/path/folder_name']})


So, how to add a folder to a project?
hellojinjie
 
Posts: 3
Joined: Fri Jul 05, 2013 5:39 am

Re: How to add folder to project use run_command

Postby hellojinjie on Mon Jul 08, 2013 8:41 am

any one help me? Thank you!
hellojinjie
 
Posts: 3
Joined: Fri Jul 05, 2013 5:39 am

Re: How to add folder to project use run_command

Postby miped on Mon Jul 08, 2013 7:56 pm

Hi,

The plugin SideBarEnhancements includes functionality like this. It involves reading and writing the project json files. You might want to take a look at these files

For ST2: https://github.com/titoBouzout/SideBarEnhancements/blob/master/sidebar/SideBarProject.py
For ST3: https://github.com/titoBouzout/SideBarEnhancements/blob/st3/sidebar/SideBarProject.py

It looks like it's a lot easier in ST3.

Alternatively, you can go ST3 only and use the window.project_data() and window.set_project_data() api. An example from the Sublime Text 3 console:
Code: Select all
>>> d = window.project_data()
>>> print(d)
{'folders': [{'path': 'project1'}]}
>>> d['folders'].append({'path': 'project2'})
>>> d
{'folders': [{'path': 'project1'}, {'path': 'project2'}]}
>>> window.set_project_data(d)
SublimeGit: Git integration for Sublime Text 2 and 3
https://sublimegit.net
miped
 
Posts: 16
Joined: Mon Jul 08, 2013 6:30 pm

Re: How to add folder to project use run_command

Postby hellojinjie on Tue Jul 09, 2013 9:04 am

Yeah, thank you ,I got it..

see my plugin https://github.com/hellojinjie/OpenCurrentFolder
hellojinjie
 
Posts: 3
Joined: Fri Jul 05, 2013 5:39 am


Return to Plugin Development

Who is online

Users browsing this forum: Google [Bot] and 7 guests