Sublime Forum

log_commands is great, but....(question)

#1

So, I completely love log_commands(True). Enough that I wanted to map some keys to turn it on! Seen a lot of discussion about using it, but not how to map it!

I’ve tried various things, my last is:
, { “keys”: “ctrl+alt+f12”], “command”: “sublime.log_commands”, “args”: { “setting”: “True” } }
, { “keys”: “ctrl+alt+f11”], “command”: “sublime.log_commands”, “args”: { “setting” : “False” } }

The problem here is that I have no idea what the ARGUMENT key name is! I’ve guessed at 50 things, and “setting” isn’t the right value. I’ve even tried this:

, { "keys": "ctrl+alt+f12"], "command": "sublime.log_commands(True) }
, { "keys": "ctrl+alt+f11"], "command": "sublime.log_commands(False) }

…and while it shows in the console, kicking it to False doesn’t actually turn off the feature. My next mousec click shows up or anything I type.

Any ideas? I tried to see if there was a setting value I could toggle, but could not find a definitely list of all Sublime 2 settings. (Other than the settings file, which has nothing for log_commands.)

I had actually thought this would be simple and straightforward. (Loving Sublime, by the way!)

0 Likes

#2

Don’t know if you can do it like that. Though you can wrap the command in a plugin pretty easily.

[code]import sublime
import sublime_plugin

class ToggleLogCommandsCommand(sublime_plugin.ApplicationCommand):
log_command_state = False
def run(self):
self.log_command_state = not self.log_command_state
sublime.status_message(“log_commands set to %s” % self.log_command_state)
sublime.log_commands(self.log_command_state)[/code]

Bind “toggle_log_commands” to the key binding of your choosing. This also has the benefit of only using one key binding instead of two. :smile:

1 Like

#3

@skuroda : Very cool, man. Exactly what I wanted. Of course, my initial reaction was: “There’s no way toggle_log_command is going to work, that text isn’t anywhere!” (Then I went and read about how to build a Sublime plugin and realized you clearly knew what you were doing.)

Thanks for the help. Once I figure out the HOW part, I’ll throw that up as a package that can be grabbed like others I’ve seen. With credit-from-the-rookie to you!

0 Likes