keys: Fix an issue with C-i/tab distinction

Before this <tab> => TAB if there is no binding for <tab>, but then
`spacemacs/translate-C-i` turned this into <C-i>, which we don't want
because that would mean having to always bind <tab> when this option is
enabled. This commit adds a check to make sure we can't possibly be
translating from <tab> originally (we only want to capture the C-i
events in the GUI).

Also, fixes C-m translation but leaves it commented.
This commit is contained in:
justbur 2015-12-04 09:37:14 -05:00
parent 8191a6695f
commit 394fec28e0
2 changed files with 18 additions and 3 deletions

View File

@ -19,13 +19,28 @@
"Base keymap for all spacemacs leader key commands.")
(defun spacemacs/translate-C-i (_)
"If `dotspacemacs-distinguish-gui-tab' is non nil, the raw key
sequence does not include <tab> or <kp-tab>, and we are in the
gui, translate to [C-i]. Otherwise, [9] (TAB)."
(interactive)
(if (and dotspacemacs-distinguish-gui-tab (display-graphic-p)) [C-i] [?\C-i]))
(if (and (not (cl-position 'tab (this-single-command-raw-keys)))
(not (cl-position 'kp-tab (this-single-command-raw-keys)))
dotspacemacs-distinguish-gui-tab
(display-graphic-p))
[C-i] [?\C-i]))
(define-key key-translation-map [?\C-i] 'spacemacs/translate-C-i)
;; (defun spacemacs/translate-C-m (_)
;; "If `dotspacemacs-distinguish-gui-ret' is non nil, the raw key
;; sequence does not include <ret>, and we are in the gui, translate
;; to [C-m]. Otherwise, [9] (TAB)."
;; (interactive)
;; (if (and dotspacemacs-distinguish-gui-ret (display-graphic-p)) [C-m] [?\C-m]))
;; (if (and
;; (not (cl-position 'return (this-single-command-raw-keys)))
;; (not (cl-position 'kp-enter (this-single-command-raw-keys)))
;; dotspacemacs-distinguish-gui-ret
;; (display-graphic-p))
;; [C-m] [?\C-m]))
;; (define-key key-translation-map [?\C-m] 'spacemacs/translate-C-m)
(defun spacemacs/declare-prefix (prefix name &optional long-name)

View File

@ -120,7 +120,7 @@ values."
;; In the terminal, these pairs are generally indistinguishable, so this only
;; works in the GUI. (default nil)
dotspacemacs-distinguish-gui-tab nil
dotspacemacs-distinguish-gui-ret nil
;; (Not implemented) dotspacemacs-distinguish-gui-ret nil
;; The command key used for Evil commands (ex-commands) and
;; Emacs commands (M-x).
;; By default the command key is `:' so ex-commands are executed like in Vim