joaotavora / yasnippet

A template system for Emacs
http://joaotavora.github.io/yasnippet/
2.81k stars 311 forks source link

Interactive local-set/unset-key broken #103

Closed joaotavora closed 13 years ago

joaotavora commented 13 years ago

What steps will reproduce the problem?

  1. Install and set up yasnippet the usual way.
  2. M-x local-unset-key RET
  3. TAB RET

What is the expected output? What do you see instead? TAB is still bound to yas-expand. The key binding should be set to nil, but isn't.

Please use labels and text to provide additional information. The minor-mode keymap somehow is prevented from being changed by define-key while the mode is activated, this shouldn't happen.

Google Code Info: Issue #: 101 Author: wyue...@gmail.com Created On: 2009-09-08T19:00:58.000Z Closed On: 2009-09-09T08:22:11.000Z

joaotavora commented 13 years ago

local-set-key' andlocal-unset-key' cannot change the keybindings set by a keymap set by any minor mode. The only keys that can be set/unset with such function are the keys of the keymap returned by `current-local-map'.

The `yas/trigger-key' is not set in that way.

Google Code Info: Author: joaotav...@gmail.com Created On: 2009-09-09T08:22:12.000Z

joaotavora commented 13 years ago

"The only keys that can be set/unset with such function are the keys of the keymap returned by `current-local-map'."

That's what I meant. current-local-map is essentially a buffer local copy of yas/minor-mode-map. Changing its binding should immediately take effect within that buffer.

With the way keys are defined in variables now, no keys can be redefined interactively and you cannot unset keys with global and local-unset-key in ELISP. Evaling, which is a hack , can unset keys, but the mnemonics are still showing in the menu. As an effort to popularize Yasnippet, this conformance to the de facto way to set key bindings will lower the learning curve of Yasnippet and Emacs in general and thus improves the user experience. Please reconsider.

Google Code Info: Author: wyue...@gmail.com Created On: 2009-09-09T16:06:02.000Z

joaotavora commented 13 years ago

Look, take a minor mode, any minor mode, a part of Emacs, for example, lets say hideshow. Turn hs-minor- mode on. Try to unset, say "C-c @ C-c" with your method. I don't think it will work, or that current-local-map is a copy of yas/minor-mode-map.

I can be wrong, my knowledge ends after "http://www.gnu.org/software/emacs/elisp/html_node/Controlling- Active-Maps.html". I'm leaving this issue in this state, but encourage you to submit a prototype that keeps all yasnippet keybinding functionality and still conform to the 'local-set-key'.

Google Code Info: Author: joaotav...@gmail.com Created On: 2009-09-09T21:00:59.000Z

joaotavora commented 13 years ago

Ah ha. My mistake. Somehow in my alternate universe I confused all the different ways to remap keys. Sorry about that. So appearently, (eval-expression (define-key yas/minor-mode-map (kbd "C-/") nil) works the way I want. Sorry about that and thanks for pointing this out.

Google Code Info: Author: wyue...@gmail.com Created On: 2009-09-09T21:15:02.000Z