Sublime Forum

Enable/Disable multiple package s with command or hotkey

#1

I do not like to commenting packages in setting, i want to quickly enable or disable group of plugin, and this is working solution but has error in console…

Work with Multicommand plugin
in Plugin Chain doesnt work

Example to disable/enable plugins (Column Select and RegReplace)

        {"caption": "Disable group packags",
          // "keys": ["super+s"],
          "command": "multicommand",
          "args": {
            "commands": [
              {"command": "disable_package",},
              {"command": "insert", "args": {"characters": "Column Select"}},
              {"command": "select"},

              {"command": "disable_package",},
              {"command": "insert", "args": {"characters": "RegReplace"}},
              {"command": "select"},
              ]}},

        {"caption": "Enable group packags",
          // "keys": ["super+s"],
          "command": "multicommand",
          "args": {
            "commands": [
              {"command": "enable_package",},
              {"command": "insert", "args": {"characters": "Column Select"}},
              {"command": "select"},

              {"command": "enable_package",},
              {"command": "insert", "args": {"characters": "RegReplace"}},
              {"command": "select"},
              ]}},

the only issues is error in console, but its working.

Error console:

Traceback (most recent call last):
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 928, in on_modified_async
run_view_callbacks(‘on_modified_async’, view_id)
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 708, in run_view_callbacks
callback(v, *args)
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 190, in exception_handler
return event_handler(*args)
File “/Users/z/Library/Application Support/Sublime Text/Installed Packages/WordCount.sublime-package/WordCount.py”, line 93, in on_modified_async
ws[‘modified’] = True
TypeError: ‘NoneType’ object does not support item assignment
Traceback (most recent call last):
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 936, in on_selection_modified_async
run_view_callbacks(‘on_selection_modified_async’, view_id)
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 708, in run_view_callbacks
callback(v, *args)
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 190, in exception_handler
return event_handler(*args)
File “/Users/z/Library/Application Support/Sublime Text/Installed Packages/WordCount.sublime-package/WordCount.py”, line 99, in on_selection_modified_async
ws[‘selection’] = True
TypeError: ‘NoneType’ object does not support item assignment
Traceback (most recent call last):
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 928, in on_modified_async
run_view_callbacks(‘on_modified_async’, view_id)
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 708, in run_view_callbacks
callback(v, *args)
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 190, in exception_handler
return event_handler(*args)
File “/Users/z/Library/Application Support/Sublime Text/Installed Packages/WordCount.sublime-package/WordCount.py”, line 93, in on_modified_async
ws[‘modified’] = True
TypeError: ‘NoneType’ object does not support item assignment
Traceback (most recent call last):
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 936, in on_selection_modified_async
run_view_callbacks(‘on_selection_modified_async’, view_id)
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 708, in run_view_callbacks
callback(v, *args)
File “/Applications/Sublime Text 4.app/Contents/MacOS/Lib/python33/sublime_plugin.py”, line 190, in exception_handler
return event_handler(*args)
File “/Users/z/Library/Application Support/Sublime Text/Installed Packages/WordCount.sublime-package/WordCount.py”, line 99, in on_selection_modified_async
ws[‘selection’] = True
TypeError: ‘NoneType’ object does not support item assignment
reloading settings Packages/User/Preferences.sublime-settings
reloading /Users/z/Library/Application Support/Sublime Text/Packages/User/Preferences.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings

If anyone has better options, I would be grateful

0 Likes

How to press enter in command palete parameter?
#2

As outlined in your other thread on this, the issue with using chain here is that you were not specifying the binding correctly, and chain is now built into ST4 so if you’re using a newer version you don’t need to install anything to get things working.

Also, the version of chain that’s built supports the argument formats for Chain of Command and MuiltiCommand (i.e. you can specify the bindings either way).

Your error traceback is related to the WordCount package being angry about something; that would seem to be unrelated to anything happening with this binding. Have you verified that you only see this error after using this key binding?

0 Likes

#3

Used Sublime 3 its fester than 4 for now. Interface lagging more…
WordCount disabeled and now all normal, thanks

the problem now is with command

{“command”: “insert”, “args”: {“characters”: “RegReplace”}},

When all plugin is disabeled or enabeled its woking normal.

When one plugin is enable and other is disable it stop working, inserting that text in file line and sometime showing command palete with all text pasted there, is there is way to checking that in parameter?

0 Likes

#5

Think found way to work it correctly with plugin Sublime Text Multi Commands

Maybe there are more elegant way to do so, but maybe somebody it helped to disable enable group of package

If somebody could write a better way I would be very appreciate.

And maybe somebody can put it to plugin with checkbox when disabeled or enabled to avoid make two menu item- Disabled Group Package and Enabled group of Package

Thanks all who helped me

for example here i disabeled packages:
Column Select
CursorRuler
KeybindingHelper

    {"caption": "Disable group packags",
      // "keys": ["super+s"],
      "command": "multicommand",
      "checkbox": true,
      "args": {
        "commands": [
          {"command": "show_overlay", "args": {"overlay": "command_palette", "text": "Disable Package"} },
          {"command": "move", "args": {"by": "lines", "forward": true} },
          {"command": "select","args": { "by": "lines", "forward": true, }, "context":[{ "key": "overlay_visible", "operator": "equal", "operand": true }]},
          {"command": "insert", "args": {"characters": "Column Select"}, "context":[{ "key": "overlay_visible", "operator": "equal", "operand": true }]},
          {"command": "select","args": { "by": "lines", "forward": true, }, "context":[{ "key": "overlay_visible", "operator": "equal", "operand": true }]},
          
          {"command": "show_overlay", "args": {"overlay": "command_palette", "text": "Disable Package"} },
          {"command": "move", "args": {"by": "lines", "forward": true} },
          {"command": "select","args": { "by": "lines", "forward": true, }, "context":[{ "key": "overlay_visible", "operator": "equal", "operand": true }]},
          {"command": "insert", "args": {"characters": "CursorRuler"}, "context":[{ "key": "overlay_visible", "operator": "equal", "operand": true }]},
          {"command": "select","args": { "by": "lines", "forward": true, }, "context":[{ "key": "overlay_visible", "operator": "equal", "operand": true }]},

          {"command": "show_overlay", "args": {"overlay": "command_palette", "text": "Disable Package"} },
          {"command": "move", "args": {"by": "lines", "forward": true} },
          {"command": "select","args": { "by": "lines", "forward": true, }, "context":[{ "key": "overlay_visible", "operator": "equal", "operand": true }]},
          {"command": "insert", "args": {"characters": "KeybindingHelper"}, "context":[{ "key": "overlay_visible", "operator": "equal", "operand": true }]},
          {"command": "select","args": { "by": "lines", "forward": true, }, "context":[{ "key": "overlay_visible", "operator": "equal", "operand": true }]},



          ]}},

0 Likes