SublimePerlTidy
SublimePerlTidy copied to clipboard
perltidy on save option?
Hi,
Another random idea - I've seen plugins ( http://www.klaascuvelier.be/2012/02/sublime-text-2-command-on-save/ ) that let you run commands on save, but thought it would be a fantastic option to have within this great plugin.
Just a though - keep up the good work :)
Leo
Hi Leo,
it's on the list for the next release.
Cheers, V.
I was able to implement this by adding a file called PerlTidyEventListener.py in ~/Library/Application Support/Sublime Text 2/Packages/PerlTidy/ with this code:
# -*- coding: utf-8 -*-
import sublime, sublime_plugin
class PerlTidyEventListener(sublime_plugin.EventListener):
def on_pre_save(self, view):
# Only run perltidy on perl files and if user requests this feature.
run_on_save = view.settings().get('perltidy_run_on_save', False)
if (run_on_save and view.match_selector(view.sel()[0].begin(), 'source.perl')):
view.run_command('perl_tidy')
It checks for a user setting of perltidy_run_on_save. If this isn't set to true it is disabled by default.