[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(global-set-key) vs (define-key)
From: |
Daniel Corbe |
Subject: |
(global-set-key) vs (define-key) |
Date: |
Thu, 25 Jun 2015 14:05:00 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
I'm trying to extend eshell so I can use it to manage routers and
switches. This necessitates changing a few important key-bindings that
equipment manufacturers tend to use.
The problem with the code below is ? works; however, both Ctrl-Z and TAB
stay bound to their original key bindings.
If I use global-set-key instead, TAB and Ctrl-Z do what they're supposed
to do.
I have a suspicion that (define-key) is not allowed to override global
bindings. Is that true? If so, what should I be using instead?
(define-derived-mode router-mode eshell-mode "Router"
"Some key bindings and tools to make dealing with routers/switches easier."
(define-key eshell-mode-map "?" 'router-mode-help-key)
(define-key eshell-mode-map (kbd "C-z") 'router-mode-end-key)
(define-key eshell-mode-map (kbd "TAB") 'self-insert-command))
(defun router-mode-help-key ()
"Defines what happens when a user hits the ? key."
(interactive)
(insert "?")
(eshell-send-input nil nil t))
(defun router-mode-end-key ()
"This sends Ctrl-Z along to the shell."
(interactive)
(eshell-kill-input)
(insert "end")
(eshell-send-input))
- (global-set-key) vs (define-key),
Daniel Corbe <=