summaryrefslogtreecommitdiff
path: root/home/dots/.emacs.d/elisp/custom-keymaps.el
blob: 7c6d614e166a7ba1bb1759275ca4a68ac578501b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(defvar keymaps-mode-map (make-sparse-keymap)
  "Keymap for `keymaps-mode'")

;;;###autoload
(define-minor-mode keymaps-mode
  "A minor mode so that my key settings override annoying major modes."
  ;; If init-value is not set to t, this mode does not get enabled in
  ;; `fundamental-mode' buffers even after doing \"(global-my-mode 1)\".
  ;; More info: http://emacs.stackexchange.com/q/16693/115
  :init-value t
  :lighter " keymaps"
  :keymap keymaps-mode-map)

;;;###autoload
(define-globalized-minor-mode global-keymaps-mode keymaps-mode keymaps-mode)

;; https://github.com/jwiegley/use-package/blob/master/bind-key.el
;; The keymaps in `emulation-mode-map-alists' take precedence over
;; `minor-mode-map-alist'
(add-to-list 'emulation-mode-map-alists `((keymaps-mode . ,keymaps-mode-map)))

;; Turn off the minor mode in the minibuffer
(defun turn-off-keymaps-mode ()
  "Turn off keymaps-mode."
  (keymaps-mode -1))
(add-hook 'minibuffer-setup-hook #'turn-off-keymaps-mode)

(provide 'custom-keymaps)