Sublime Forum

sublime_plugin.EventListener.on_post_save API

#1

I’ve been evaluating Sublime Text 2 for the past week(ish) and am pretty happy with what I’ve encountered. I’m currently trying to get syntax coloring working how I’d like by using this

gist.github.com/1497794

My current problem is when creating a new file. Once it is saved, the script gets executed and the message that the syntax was set gets printed in the console, but the syntax is then changed by something in Sublime after the on_post_save call. As an example, I create a new file that will be an RSpec spec file. When I save it, I see in the console the message “Switched syntax to: RSpec”, but the syntax ultimately becomes Ruby. I added the on_activated call so I could get the syntax changed correctly by clicking off and then back onto the new file. Ideally, I wouldn’t have to do that.

My questions are:

  • What kinds of things happen in the save process after on_post_save is fired?
  • Is there a better way to do what I’m I’m trying to do?

Thanks.

0 Likes

#2

What build of Sublime Text are you using? I think this will be working as expected in the current dev build.

0 Likes

#3

Currently using 2139. Is there a link that describes the process of evaluating a dev build?

The following is not meant to be a complaint, but a light-hearted glimpse into a programmer’s reality…

For the record, I’ve burned almost two days playing around with syntax highlighting and various things in Sublime Text 2, and I’m having a great time. I keep thinking, “I’m not getting paid right now … oh well, I’m having fun.” The only thing that would make it better would be the ability to script in Ruby instead of Python. No offense to Python, but Ruby is my preference.

Thanks for a great tool.

0 Likes

#4

Dev builds can be found here:

sublimetext.com/dev

You can switch between the stable/dev channels at any time. sublime.channel() will give you the current channel you’re on.

0 Likes

#5

I just verified that the on_post_save does work the way I expect it to with build 2150. I commented out the on_activated callback and created a new RSpec file and on saving it, it was assigned the correct syntax.

As my daughter would say, ‘Hupungus!’

Thanks.

0 Likes