Opened 4 years ago

Closed 4 years ago

#1168 closed enhancement (fixed)

Allow plugins to hook into the on_save method

Reported by: szabgab Owned by:
Priority: major Milestone:
Component: editor Version: 0.85
Keywords: Cc:

Description (last modified by szabgab)

We discussed on IRC that it would be interesting to allow the Perl Tidy plugin to run on the current file on every save.

There were some discussion about pulling the plugin into core but IMHO this is an opportunity to see if we can enable the plugins to hook into the on_save method of Padre.

Ideas:

The plugin can have a method called on_save and it will be called on every save.

The plugin can have a method called padre_hooks that will
return a hash-ref. In that hash-ref we can have a key called on_save with the value being a sub-ref.

The latter makes the hooks system more extend-able and less likely interference with current methods of plugins.

If more than one plugin provides the same hooks we need to decide in which order they are called. I'd suggest to start with the abc order of the plugins.

Change History (5)

comment:1 Changed 4 years ago by szabgab

  • Description modified (diff)

comment:2 Changed 4 years ago by szabgab

See also #15

comment:3 Changed 4 years ago by Sewi

The plugin should optionally be able also set a "priority" value for it's subref.
They could be called sorted by priority and then abc, setting no priority will use a default value. Default value'd plugins will be called last.

Maybe "before_save" and "after_save" hooks might be better (clearer).

comment:4 follow-up: Changed 4 years ago by Sewi

Wiki page for this: PluginAPI/Padre_Hooks

comment:5 in reply to: ↑ 4 Changed 4 years ago by Sewi

  • Resolution set to fixed
  • Status changed from new to closed

landed in r14090

Note: See TracTickets for help on using tickets.