1

I use C-Tab and C-Shift-Tab to navigate buffer as I would do in a browser. Unfortunately, in magit-mode (which I call using magit-status), the key is bound to some diff expansion. The means that I can't switch buffers the ways I would like to as soon as one buffer is in magit-mode. I tried removing the binding using

(define-key magit-mode-map
    (kbd "C-<Tab>") nil)

However, this does not seem to have any effect. Any ideas on how to fix this?

Edit:

Regarding my settings: I have a .emacs.d/buffers.el which has a line defining the key binding: (global-set-key [C-tab] 'next-buffer).

I am using use-package to load magit:

(use-package magit
  :ensure t
  :config
  (define-key magit-mode-map (kbd "C-<Tab>") nil)
  (with-eval-after-load 'magit-mode
    (define-key magit-mode-map (kbd "<C-Tab>") nil))
  (setq magit-display-buffer-function
        (lambda (buffer)
          (display-buffer buffer '(display-buffer-same-window)))))

I added the suggestion by Konstantin Morenko, but C-Tab still does not work properly.

3

According to Remove key binding in magit-status-mode use in init.el

(with-eval-after-load 'magit-mode
  (define-key magit-mode-map (kbd "<C-Tab>") nil))

The (with-eval-after-load FILE &opt BODY) executes BODY after the FILE is loaded, so, it will rebind keys only after the keybind in magit-mode will be created.

Edit:

From the documentation of bind-key.el from use-package

;; If you have lots of keybindings set in your .emacs file, it can be hard to
;; know which ones you haven't set yet, and which may now be overriding some
;; new default in a new emacs version.  This module aims to solve that
;; problem.
;;
;; Bind keys as follows in your .emacs:
;;
;;   (require 'bind-key)
;;
;;   (bind-key "C-c x" 'my-ctrl-c-x-command)
;;
;; If you want the keybinding to override all minor modes that may also bind
;; the same key, use the `bind-key*' form:
;;
;;   (bind-key* "<C-return>" 'other-window)

So, use in your buffers.el

(require 'bind-key)
(bind-key "<C-Tab>" 'next-buffer)
  • Thx, I used bind-key* and everything works perfectly. – hfhc2 Jul 29 '16 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.