Home Download Buy Blog Forum Support

Plugin API

Plugin API

Postby jps on Sat Mar 22, 2008 3:37 pm

I've just released beta 20080322, which comes with a published API. Docs are at:

http://www.sublimetext.com/docs/plugin-basics
http://www.sublimetext.com/docs/plugin-examples
http://www.sublimetext.com/docs/api-reference

There's still more functionality that needs to be exposed, and more introductory documentation that needs to be written, but I feel this is a pretty good start.

I haven't mentioned it in any of the above docs, but within the console you have access to two variables, view and window, which are a good place to start exploring.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Plugin API

Postby SteveCooperOrg on Sat Mar 22, 2008 5:07 pm

Damn! now I have to learn python ;)

Fantastic, Jon, thanks.
Maybe what you're looking for is at the http://www.sublimetextwiki.com
SteveCooperOrg
 
Posts: 193
Joined: Thu Mar 20, 2008 9:53 am

Re: Plugin API

Postby jps on Sun Mar 23, 2008 1:19 pm

You want to call view.substr() with a region encompassing the entire buffer, e.g.,

view.substr(sublime.Region(0, view.size()))
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Plugin API

Postby SteveCooperOrg on Tue Mar 25, 2008 5:05 pm

Hi, Jon. I wanted to know if there was a way yet to use the sublime.Options class to set a plugin-specific option?

I'm trying to improve my auto-backup plugin so that the user can add the backup dir as a preference. I'd like the user to modify easily-accessible preferences -- say Application.sublime-options -- and add

Code: Select all
plugin.AutoBackupPlugin.autoBackupDir c:\usr\backups\


Then, my code can read;

Code: Select all
backupDir = view.options().getString("plugin.AutoBackupPlugin.autoBackupDir")


and let the user specify the option without hacking the python file. Is there any way to do this, or anything like it? I can get file-type-specific options (eg, I can set autoBackupDir in Python.sublime-options and read that, but there seems to be no inheritance from the application options.)

ALSO -- can I suggest a Advanced Customisation forum, for python API, macros, theme development, etc?
Maybe what you're looking for is at the http://www.sublimetextwiki.com
SteveCooperOrg
 
Posts: 193
Joined: Thu Mar 20, 2008 9:53 am

Re: Plugin API

Postby jps on Wed Mar 26, 2008 5:30 am

Yeah, only file type options are exposed atm - I'll change that for tonights beta.

All file type options inherit from Packages/Default/Options/Default.sublime-objects, but it's probably best to put something like the backup dir in the application options.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm


Return to Plugin Announcements

Who is online

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