noctuid / general.el

More convenient key definitions in emacs
GNU General Public License v3.0
986 stars 43 forks source link

buffer-local keybinding for non-major mode map #176

Open matthuszagh opened 4 years ago

matthuszagh commented 4 years ago

Thanks for this terrific package!

Is there a way to set a buffer-local keybinding for a keymap other than the major mode map. I normally use company-complete-selection for completions, but in eshell-mode I'd like to bind my completion key to company-complete-common. This completion key needs to be bound in company-active-map, not eshell-mode-map. I've tried using local, but that seems to just be for buffer-local bindings in the major mode map. For instance, I haven't had any luck with this:

(add-hook 'eshell-mode-hook (lambda ()
                                 (general-define-key
                                  :keymaps 'local
                                  "<tab>" 'company-complete-common)))

But, as expected, it does bind tab in eshell-mode-map.

noctuid commented 4 years ago

You could maybe make company-active-map buffer local ((make-local-variable 'company-active-map) in eshell-mode-hook) and then bind your key in company-active-map.