Home Download Buy Blog Forum Support

How to force a build on save?

How to force a build on save?

Postby 4x13 on Thu Sep 22, 2011 5:10 am

I started using Sublime Text 2 very recently, awesome feedback so far. I have a project created in ST2 with a make file, which I'm able to build using a CMD+B combination. The build is blazingly fast, so I'm trying to figure ways to avoid that extra CMD+B combination and tie it to a save operation. Is there a way to trigger a build on each save operation in a project?

Thanks for the support.
4x13
 
Posts: 3
Joined: Thu Sep 22, 2011 5:07 am

Re: How to force a build on save?

Postby bizoo on Thu Sep 22, 2011 6:16 am

Is 'Save All on Build' option an option for you ?
bizoo
 
Posts: 873
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: How to force a build on save?

Postby 4x13 on Fri Sep 23, 2011 3:49 am

Thanks for replying. Save on build wouldn't work for my requirement. What I'm looking for is exactly the opposite, a 'Build on Save' option.
4x13
 
Posts: 3
Joined: Thu Sep 22, 2011 5:07 am

Re: How to force a build on save?

Postby bizoo on Fri Sep 23, 2011 6:43 am

Actually if you have not other requirement, I don't see why replacing 'Save' step by 'Build' step in your workflow doesn't resolve your issue :?:
Anyway, you could probably write a plugin that trigger a 'build' command on the 'on_post_save' event, something like that (not tested):
Code: Select all
class AutoBuildOnSave(sublime_plugin.EventListener):
    def on_post_save(self, view):
        view.run_command('build')
bizoo
 
Posts: 873
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: How to force a build on save?

Postby 4x13 on Sat Sep 24, 2011 7:02 am

Thanks bizoo. I actually ended up writing the same yesterday. I would've saved a lot of trouble if I had seen your recent post before I sat down to learn the syntax of Sublime plugins and a bit of Python.

I've hosted the same on my GitHub in case anyone is looking for the same functionality.
https://github.com/alexnj/SublimeOnSaveBuild

I would want to add a menu item with a checkbox so that it can be easily enabled or disabled for projects that need or don't need the functionality, instead of removing the plugin from the file system to do the same. I couldn't figure out from the API docs how to add a checkbox to a menu item though, pretty much everything else is ready for the same :)

Thanks for the support, once again.
4x13
 
Posts: 3
Joined: Thu Sep 22, 2011 5:07 am

Re: How to force a build on save?

Postby paul_ on Sat Apr 07, 2012 10:41 am

Hi, I extended your Plugin with a setting "saveOnBuild", so you can disable it by default and only activate it in specific projects within the project settings. Works for me very well: https://github.com/lunow/SublimeOnSaveBuild

:)
paul_
 
Posts: 1
Joined: Sat Apr 07, 2012 10:39 am


Return to Technical Support

Who is online

Users browsing this forum: pete340 and 12 guests