What I want to accomplish is to add a keybinding
C-<backspace> to the
eshell-mod-map that calls
func. That can be done like this,
(use-package eshell :init (defun add-func-keybinding () (define-key eshell-mode-map (kbd "C-<backspace>") (lambda () (interactive) (func "arg")))) :hook (eshell-mode . add-func-keybinding))
C-<backspace> only calls
func when inside an eshell buffer. I thought this should be equivalent to,
(use-package eshell :after esh-mode :bind (:map eshell-mode-map ("C-<backspace>" . (lambda () (interactive) (func "arg")))))
However, this binds
func everywhere, e. g., if I press
C-<backspace> in the
*scratch* buffer, that also calls
func. This does not happen when the configuration is done as in the former
use-package declaration, there the keybinding is kept only inside the eshell buffer.
However, I fail to see the difference between the two declarations. I would like to fix the latter so it has the same effect as the former, since the latter is a bit clearer and nicer. How can I do this?