wiki:PluginAPI/Padre_Hooks

Version 6 (modified by Sewi, 4 years ago) (diff)

--

Padre Plugin API hooks

Plugins could add hooks to Padre core functions.

Each of the following hooks is a key in the hash reference returned by the padre_hooks method of a plugin.

The value should be

  • a code reference
  • an array ref of code references

The first argument of all hooks is the plugin object = the hook is called like a method of the plugin. This argument isn't shown in the hook list.

Related tickets: #1168

Note: The list should be sorted alphabetically ignoring "before_" and "after_" prefixes of hooks

Note2: The usage samples should give you a hint how a hook could be used. They may not be useful for other cases (like svn auto-commit).

before_save

Arguments Padre::Document object being saved
Return value undef or text
Called before any file is written to disk
Usage Example tidy Perl source on every save

This hook should return undef if everything is ok. Any returned text is treated as an error message and shown to the user. The save process is stopped on the first hook returning an error message. Return an empty, but defined string will about save but not show any error, use this only to override Padre's internal save!

after_save

Arguments Padre::Document object being saved
Return value ignored
Called after any file is written to disk
Usage Example svn commit on save