Sublime Forum

ST3 API changes and Will Bond's plugin tutorial

#1

Hi,

I still don’t get some details about the ST3 API changes. Here are a couple of concrete questions (one refers to Will Bond’s ST2 plugin tutorial):

  1. The plugin API is now thread-safe. Does that mean that I can call API functions from a thread? In ST2, I always had to do the API calls from the main plugin thread and not from the threaded code (e.g. call to sublime.status_message).
  2. What are the new asynchronous API events? on_modified_async is the example in the beta ST3 beta blog post and I guess behaves like on_modified but in a separate thread. Is there a list anywhere because I can’t find them in the API documentation at sublimetext.com/docs/3/api_r … ntListener
  3. What does “Projects are exposed to the API” mean?
  4. Will Bond’s ST2 plugin tutorial is great (link below) particularly because it is a little more advanced and covers threading. Can anyone comment on how ST3 affects the the stuff covered in the tutorial? net.tutsplus.com/tutorials/pytho … -2-plugin/

ST3 API changes (from blog post)
API: Upgrade from Python 2.6 to Python 3.3
API: Plugins run out-of-process
API: Plugin API is now thread-safe
API: Some API events are now run asynchronously
API: begin_edit() / end_edit() are no longer accessible
API: Projects are exposed to the API
API: Added window.settings() and window.template_settings()
API: show_quick_panel() accepts an on_highlighted callback

0 Likes

#2
  1. A list of the asynchronous API events is here: sublimetext.com/docs/3/porting_guide.html
0 Likes

#3

Another API change I’ve come across is that sublime.Region’s method xpos() from ST2 is now the property xpos in ST3. It remains undocumented though it has been talked about before: https://forum.sublimetext.com/t/caret-position/6574/1

0 Likes

#4
  1. You can call API functions from any thread now. Be aware though, if you are calling a function from an alternate thread, that the user can be typing etc as your function is running, so the buffer will be changing underneath you.

  2. There are new functions window.project_data() and window.set_project_data()

0 Likes