reddit / emacs

make global key combinations also work in org mode

RepublicWorried · 2022-10-30 17:36
I use e.g. the following to not only define a global key mapping but make it also work within org mode ​ (global-set-key (kbd "C-c C-n") 'switch-to-buffer) (define-key org-mode-map (kbd "C-c C-n") 'switch-to-buffer) is there an easier and shorter way to make this binding work in all modes of emacs? I know aobut \*bind-keys of John Wigley but thats a workaround I want to avoid if possible
ieure · 2022-10-30 18:00
Global bindings are overridden by minor modes. Make your own minor mode for anything you want to take precedence over a major mode's bindings.
RepublicWorried · 2022-10-30 18:49
can you give me advise on how to to that?
ieure · 2022-10-30 18:58
(define-minor-mode personal-bindings "My personal bindings" :init-value t :lighter nil :keymap (make-sparse-keymap)) (define-key personal-bindings-map ...)
7890yuiop · 2022-10-31 01:25
https://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs