[wingide-users] autocmd with scripting api

Wingware Support support at wingware.com
Thu Jul 28 12:01:17 EDT 2005

On Wed, 27 Jul 2005, Chris Grebeldinger wrote:
>             I haven't found anything about this in the scripting API files,
> I was wondering if there is any way to have a script run when a document is
> saved.  Similar to what you would get with vim:

Yes, although it's not as simple.  You need to connect to either the 
'presave' or 'save-point' signal on the CAPIDocument object.  
Something like:

doc.connect('presave', mycallback)

The args sent to the callback are documented in the wingapi.py file.

You can use gApplication.GetAllDocuments() on the app API to connect 
initially to already-open docs and the 'editor-open' signal on the app 
to connect to newly opened ones.

One caveat:  I think 'presave' my not work in Wing 2.0.3 -- you may 
need to add 'presave' to the list passed to the CDestroyable.__init__ 
in the CAPIDocument.__init__.

Also, note that the save-point signal is emitted also when an editor
leaves the save point by being modified, and it is emitted w/ 1 
(arrived at save point) also if an undo gets you back to the state
that the buffer matches disk.  If that's a problem, please let me 
know.  The API is still somewhat in flux.


Stephan Deibel

Wing IDE for Python
Advancing Software Development


More information about the wingide-users mailing list