Browse files

Allow remove attributes and tags via commands and custom arguments

  • Loading branch information...
1 parent 37159ce commit 27c81ee20e1223dd880da182c261357fe08542c3 @titoBouzout committed Mar 8, 2012
Showing with 28 additions and 16 deletions.
  1. +14 −8 tag_remove.py
  2. +14 −8 tag_remove_attributes.py
View
22 tag_remove.py
@@ -30,10 +30,13 @@ def run(self, edit):
self.view.replace(edit, dataRegion, data);
class TagRemovePickedInSelectionCommand(sublime_plugin.TextCommand):
- def run(self, edit):
- import functools
- self.view.window().run_command('hide_panel');
- self.view.window().show_input_panel("Remove the following tags:", '', functools.partial(self.on_done, edit), None, None)
+ def run(self, edit, tags = False):
+ if not tags:
+ import functools
+ self.view.window().run_command('hide_panel');
+ self.view.window().show_input_panel("Remove the following tags:", '', functools.partial(self.on_done, edit), None, None)
+ else:
+ self.on_done(edit, tags);
def on_done(self, edit, tags):
for region in self.view.sel():
@@ -44,10 +47,13 @@ def on_done(self, edit, tags):
self.view.replace(edit, dataRegion, data);
class TagRemovePickedInDocumentCommand(sublime_plugin.TextCommand):
- def run(self, edit):
- import functools
- self.view.window().run_command('hide_panel');
- self.view.window().show_input_panel("Remove the following tags:", '', functools.partial(self.on_done, edit), None, None)
+ def run(self, edit, tags = False):
+ if not tags:
+ import functools
+ self.view.window().run_command('hide_panel');
+ self.view.window().show_input_panel("Remove the following tags:", '', functools.partial(self.on_done, edit), None, None)
+ else:
+ self.on_done(edit, tags);
def on_done(self, edit, tags):
dataRegion = sublime.Region(0, self.view.size())
View
22 tag_remove_attributes.py
@@ -34,10 +34,13 @@ def run(self, edit):
self.view.replace(edit, dataRegion, data);
class TagRemovePickedAttributesInSelectionCommand(sublime_plugin.TextCommand):
- def run(self, edit):
- import functools
- self.view.window().run_command('hide_panel');
- self.view.window().show_input_panel("Remove the following attributes:", '', functools.partial(self.on_done, edit), None, None)
+ def run(self, edit, attributes = False):
+ if not attributes:
+ import functools
+ self.view.window().run_command('hide_panel');
+ self.view.window().show_input_panel("Remove the following attributes:", '', functools.partial(self.on_done, edit), None, None)
+ else:
+ self.on_done(edit, attributes)
def on_done(self, edit, attributes):
for region in self.view.sel():
@@ -48,10 +51,13 @@ def on_done(self, edit, attributes):
self.view.replace(edit, dataRegion, data);
class TagRemovePickedAttributesInDocumentCommand(sublime_plugin.TextCommand):
- def run(self, edit):
- import functools
- self.view.window().run_command('hide_panel');
- self.view.window().show_input_panel("Remove the following attributes:", '', functools.partial(self.on_done, edit), None, None)
+ def run(self, edit, attributes = False):
+ if not attributes:
+ import functools
+ self.view.window().run_command('hide_panel');
+ self.view.window().show_input_panel("Remove the following attributes:", '', functools.partial(self.on_done, edit), None, None)
+ else:
+ self.on_done(edit, attributes)
def on_done(self, edit, attributes):
dataRegion = sublime.Region(0, self.view.size())

0 comments on commit 27c81ee

Please sign in to comment.