Can't bind Ctrl+Alt+I
pdg137 opened this issue · 5 comments
I have tried everything possible to get Ctrl+Alt+I bound:
(package-initialize)
(require 'use-package)
(use-package bind-key :ensure t)
(bind-key* "C-M-i" #'windmove-up)
(global-set-key (kbd "C-M-i") #'windmove-up)
(use-package ergoemacs-mode :ensure t)
(ergoemacs-component my-ergoemacs-keys ()
"My ergoemacs keys"
(global-set-key (kbd "C-M-i") #'windmove-up)
)
(ergoemacs-require 'my-ergoemacs-keys)
But no matter what I do, it seems that ergoemacs-mode is overriding that keybinding, remapping it to scroll-other-window-down
. The bind-key*
commands do succeed in binding that key as long as I have not loaded ergoemacs-mode. Is there a way to bind this particular key? By the way, the J, K, and L keys work fine; it's only Ctrl+Alt+I that has the problem.
The problem is probably you have to do funky things with Ctrl+i otherwise known as TAB to emacs.
ergoemacs-mode
had some work-arounds for this but I'm unsure if they still work AND they will only work in GUI emacs. If you are still interested, you will have to use an ergoemacs-theme-component and add it to your current ergoemacs-theme
.
I just noticed you used the ergoemacs-theme
includes the C-M-i
key.
I guess because of the work-around ergoemacs-mode uses it doesn't allow more than one C-M-i
key.
I guess one way to fix it is to remove the definition from ergoemacs by the following:
(ergoemacs-component my-move-char ()
"Movement by Characters & Set Mark"
(global-set-key (kbd "C-b") nil)
(global-set-key (kbd "M-j") ("C-b" :emacs))
(global-set-key (kbd "C-f") nil)
(define-key global-map (kbd "M-l") ("C-f" :emacs))
(global-set-key (kbd "C-p") nil)
(define-key (current-global-map) (kbd "M-i") ("C-p" :emacs))
(global-set-key (kbd "C-n") nil)
(define-key ergoemacs-keymap (kbd "M-k") ("C-n" :emacs))
;; These are here so that C-M-i will translate to C-<up> for modes
;; like inferior R mode. That allows the command to be the last
;; command.
;; Not sure it belongs here or not...
(global-set-key (kbd "M-C-j") ("<C-left>" :emacs))
(global-set-key (kbd "M-C-l") ("<C-right>" :emacs))
(global-set-key (kbd "M-C-i") #'windmove-up)
(global-set-key (kbd "M-C-k") ("<C-down>" :emacs))
(global-set-key (kbd "C-SPC") nil) ;; Set Mark
(global-set-key (kbd "M-SPC") ("C-SPC" :emacs))
;; Mode specific changes
(define-key browse-kill-ring-mode-map (kbd "M-i") 'browse-kill-ring-previous)
(define-key browse-kill-ring-mode-map (kbd "M-k") 'browse-kill-ring-forward)
;; Delete previous/next char.
(global-set-key (kbd "M-d") 'delete-backward-char)
(global-set-key (kbd "C-d") nil)
(global-set-key (kbd "M-f") 'delete-char)
;; Mode specific changes
(define-key browse-kill-ring-mode-map (kbd "M-i") 'browse-kill-ring-backward)
(define-key browse-kill-ring-mode-map (kbd "M-k") 'browse-kill-ring-forward)
(define-key browse-kill-ring-mode-map (kbd "M-f") 'browse-kill-ring-delete)
(when iswitchb-define-mode-map-hook
(define-key iswitchb-mode-map [remap backward-char] 'iswitchb-prev-match)
(define-key iswitchb-mode-map [remap forward-char] 'iswitchb-next-match))
:version 5.7.5
(global-set-key (kbd "C-SPC") 'set-mark-command) ;; Set Mark
)
Then create your own theme...
(ergoemacs-theme my-theme ()
"my Ergoemacs Theme"
:components '(copy
dired-tab
dired-to-wdired
execute
fixed-newline
help
kill-line
misc
move-bracket
move-buffer
my-move-char
move-line
move-page
move-paragraph
move-word
search
select-items
switch
text-transform
ergoemacs-remaps
standard-vars)
:optional-on '(apps-punctuation
tab-indents-region
icy-reclaim
apps-apps
apps-toggle
apps
backspace-del-seq
backspace-is-back
fn-keys
f2-edit
fixed-bold-italic
standard-fixed
ido-remaps
helm-remaps
helm-find-files
multiple-cursors-remaps
quit
apps-swap
;;save-options-on-exit
;; Reverse menu-bar order
menu-bar-help
menu-bar-languages
menu-bar-view
menu-bar-search
menu-bar-edit
menu-bar-file
mode-line-major-mode-switch
)
:optional-off '(guru
alt-backspace-is-undo
search-reg
no-backspace
helm-switch-sources
ergoemacs-banish-shift
move-and-transpose-lines
move-sexp
ido-prev-next-instead-of-left-right
join-line
save-options-on-exit
isearch-arrows
ergoemacs-swiper)
:options-menu '(("Menu/Apps Key" (apps apps-apps apps-punctuation apps-toggle))
("Function Keys" (fn-keys f2-edit))
("Helm Options" (helm-switch-sources helm-find-files))
("Remaps" (ido-remaps helm-remaps multiple-cursors-remaps icy-reclaim ergoemacs-swiper))
("Extreme ErgoEmacs" (guru no-backspace ergoemacs-banish-shift))
("Standard Keys" (standard-fixed fixed-bold-italic quit move-and-transpose-lines alt-backspace-is-undo))
("Keys during Key Sequence" (f2-edit apps-swap backspace-del-seq))
("Disputed Keys" (ido-prev-next-instead-of-left-right move-sexp))
("Extra Functionality" (join-line isearch-arrows))
("Packages" (avy multiple-cursors expand-region))
("Mode Line" (mode-line-major-mode-switch))
("Ergoemacs global menus" (menu-bar-file menu-bar-edit menu-bar-search menu-bar-view menu-bar-languages menu-bar-help))))
I have not tested this, but I believe it will work. You will have to select your new theme of course:
(setq ergoemacs-theme "my-theme")
Well, I tried pasting all of that into my startup file and rearranging it various ways, but no matter what, C-M-i
always gets bound to something different from what I specified. I did notice that I could remove move-page
from the list of components to disable the scroll-other-window-down
binding. But then it seems to return to its default Emacs binding, which is mode-dependent.
This seems to work! I don't quite understand why C-M-i
is treated differently from other keys, but removing move-page
and unbinding my key from existing mode maps gets it working everywhere.
(package-initialize)
(require 'use-package)
(use-package bind-key :ensure t)
;; unbind C-M-i from all mode maps
(unbind-key "C-M-i" emacs-lisp-mode-map)
;; need to add more...
;; Add bindings for the windmove commands.
;; Note: bind-key* does not seem to work here.
(bind-key "C-M-i" #'windmove-up)
(bind-key "C-M-k" #'windmove-down)
(bind-key "C-M-j" #'windmove-left)
(bind-key "C-M-l" #'windmove-right)
;; Page motion commands from move-page, which is
;; disabled below.
(bind-key "M-I" #'scroll-down-command)
(bind-key "M-K" #'scroll-up-command)
(require 'ergoemacs-mode)
(ergoemacs-theme my-theme ()
"my Ergoemacs Theme"
:components '(copy
dired-tab
dired-to-wdired
execute
fixed-newline
help
kill-line
misc
move-bracket
move-buffer
move-char
move-line
; move-page <-- disabled since I want C-M-i
move-paragraph
move-word
search
select-items
switch
text-transform
ergoemacs-remaps
standard-vars)
:optional-on '(apps-punctuation
tab-indents-region
icy-reclaim
apps-apps
apps-toggle
apps
backspace-del-seq
backspace-is-back
fn-keys
f2-edit
fixed-bold-italic
standard-fixed
ido-remaps
helm-remaps
helm-find-files
multiple-cursors-remaps
quit
apps-swap
;;save-options-on-exit
;; Reverse menu-bar order
menu-bar-help
menu-bar-languages
menu-bar-view
menu-bar-search
menu-bar-edit
menu-bar-file
mode-line-major-mode-switch
)
:optional-off '(guru
alt-backspace-is-undo
search-reg
no-backspace
helm-switch-sources
ergoemacs-banish-shift
move-and-transpose-lines
move-sexp
ido-prev-next-instead-of-left-right
join-line
save-options-on-exit
isearch-arrows
ergoemacs-swiper)
:options-menu '(("Menu/Apps Key" (apps apps-apps apps-punctuation apps-toggle))
("Function Keys" (fn-keys f2-edit))
("Helm Options" (helm-switch-sources helm-find-files))
("Remaps" (ido-remaps helm-remaps multiple-cursors-remaps icy-reclaim ergoemacs-swiper))
("Extreme ErgoEmacs" (guru no-backspace ergoemacs-banish-shift))
("Standard Keys" (standard-fixed fixed-bold-italic quit move-and-transpose-lines alt-backspace-is-undo))
("Keys during Key Sequence" (f2-edit apps-swap backspace-del-seq))
("Disputed Keys" (ido-prev-next-instead-of-left-right move-sexp))
("Extra Functionality" (join-line isearch-arrows))
("Packages" (avy multiple-cursors expand-region))
("Mode Line" (mode-line-major-mode-switch))
("Ergoemacs global menus" (menu-bar-file menu-bar-edit menu-bar-search menu-bar-view menu-bar-languages menu-bar-help))))
(setq ergoemacs-theme "my-theme")
Its about emacs being old and interpreting keys for terminals.
https://emacs.stackexchange.com/questions/17509/how-to-distinguish-c-i-from-tab
has some context.
Other keys you may have problems with are C-m
and C-[
, M-O
and M-[
One of the recurrant ergoemacs-mode issues has to do with how these keys are determined.
There are some tricky things that have to be done to handle these keys.