Temporarily disable triggers on insert key (like emacs quoted-insert)?



I often have to type a " without wanting the closing ", (or a (, {, etc). I also sometimes want to type a # inside an interpolated string (ruby, coffeescript) without wanting a #{}. I simply resolve by just typing the key and delete the unwanted character(s). But sometimes this gets very slow, like typing the string “###########”.

I am very happy with emacs’s quoted-insert function, where you type C-q " and obtain a single ", no matter what. Where would I have to start looking to implement something like this?

Of course, it there’s an easy solution, please just tell me, but I’m really asking for documentation or source code to read: there are a few things I’d like to be able to do with Atom, but it seems I’m totally unable to find my way around stuff: I can’t even find out which package triggers # -> #{} in interpolated strings, and I have no idea how to find out, apart from disabling everything and then start enabling packages back, which is kind of impractical. I hoped Key Binding Resolver would helped me, but it didn’t: it has nothing to say about #, " etc.


The bracket-matcher package is the one that performs all of the matching inserts that you’re talking about. There isn’t a method of disabling matching but after some quick experimentation, one shouldn’t be too hard to build. If you use the TextEditor.insertText method, brackets are matched. But if you use Selection.insertText, brackets aren’t matched. You could use that quality to make a key binding like Shift+Ctrl+3 insert a # without the curly braces.


My somewhat confuse idea would be, inside bracket-matcher:

  1. define a command that sets something to !something;
  2. inside BrackerMatcher#insertText, if something is true, return true.

This means I could bind the command to a key and then bracket-matcher would be temporarily disabled until I press the button again.

I could also optionally have a slightly different command that sets the something to 'just-once', and then set it back to false in insertText right before returning, so I could press a key and then insert just one character (quote, #, etc) without the behaviour of bracket-matcher.

I have no idea what that something should be, though. I think I should modify the scope, but I’m not sure. Suggestions?

Then, question: am I the only one that would like to see this, or may it be worth trying to make a pull request?