Use the custom-bindings-map

This commit is contained in:
larstvei 2023-06-21 13:19:59 +02:00
parent ecbdf40171
commit e9d6556bf1

View File

@ -310,6 +310,20 @@
#+end_src
* Key bindings
Inspired by [[http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs][this StackOverflow post]] I keep a =custom-bindings-map= that holds
all my custom bindings. This map can be activated by toggling a simple
=minor-mode= that does nothing more than activating the map. This inhibits
other =major-modes= to override these bindings.
#+begin_src emacs-lisp
(defvar custom-bindings-map (make-keymap)
"A keymap for custom bindings.")
#+end_src
* Modal meow
I have been wanting to try out modal editing. [[https://github.com/meow-edit/meow][meow]] seems like a nice package,
@ -563,7 +577,7 @@
;; Minor mode for a nice writing environment
(use-package olivetti
:defer t
:bind ("C-c o" . olivetti-mode)
:bind (:map custom-bindings-map ("C-c o" . olivetti-mode))
:config
(setq-default olivetti-body-width (+ fill-column 3))
(remove-hook 'olivetti-mode-on-hook 'visual-line-mode))
@ -580,7 +594,7 @@
;; Dim color of text in surrounding sections
(use-package focus
:defer t
:bind ("C-c f" . focus-mode))
:bind (:map custom-bindings-map ("C-c f" . focus-mode)))
#+end_src
@ -686,7 +700,7 @@
;; A Git porcelain inside Emacs.
(use-package magit
:bind ("C-c m" . magit-status))
:bind (:map custom-bindings-map ("C-c m" . magit-status)))
#+end_src
@ -722,7 +736,7 @@
;; Manage and navigate projects in Emacs easily
(use-package projectile
:bind ("C-c p" . projectile-command-map))
:bind (:map custom-bindings-map ("C-c p" . projectile-command-map)))
#+end_src
@ -738,7 +752,7 @@
;; Incremental Vertical completion
(use-package ivy
:bind ("C-x b" . ivy-switch-buffer)
:bind (:map custom-bindings-map ("C-x b" . ivy-switch-buffer))
:config
(setq ivy-wrap t ; Easier access to the last candidate
ivy-height 25 ; Give me more candidates to look at
@ -766,14 +780,13 @@
Use counsel for =M-x=, yanking and finding files.
#+begin_src emacs-lisp
;; Various completion functions using Ivy
(use-package counsel
:bind
(("M-x" . counsel-M-x)
(:map custom-bindings-map
("M-x" . counsel-M-x)
("M-y" . counsel-yank-pop)
("C-x C-f" . counsel-find-file)))
#+end_src
Use swiper for fancy search.
@ -782,7 +795,7 @@
;; Isearch with an overview. Oh, man!
(use-package swiper
:bind ("C-c i" . swiper-isearch))
:bind (:map custom-bindings-map ("C-c i" . swiper-isearch)))
#+end_src
@ -916,7 +929,7 @@
;; display the definition of word at point
(use-package define-word
:defer t
:bind ("C-c D" . define-word-at-point))
:bind (:map custom-bindings-map ("C-c D" . define-word-at-point)))
#+end_src
@ -1162,7 +1175,7 @@
(executable-find "mbsync")
(executable-find "msmtp")
(executable-find "mu"))
:bind ("C-x m" . mu4e)
:bind (:map custom-bindings-map ("C-x m" . mu4e))
:config
(setq
mail-user-agent 'mu4e-user-agent
@ -1230,7 +1243,8 @@
;; Multiple cursors for Emacs
(use-package multiple-cursors
:defer t
:bind (("C-c e" . mc/edit-lines)
:bind (:map custom-bindings-map
("C-c e" . mc/edit-lines)
("C-c a" . mc/mark-all-like-this)
("C-c n" . mc/mark-next-like-this)))
@ -1245,7 +1259,7 @@
;; Increase selected region by semantic units
(use-package expand-region
:defer t
:bind ("C-=" . er/expand-region))
:bind (:map custom-bindings-map ("C-=" . er/expand-region)))
#+end_src
@ -1546,7 +1560,8 @@
(t (vterm buffer-name)
(rename-buffer buffer-name))))))
:bind (("C-z" . toggle-vterm)
:bind (:map custom-bindings-map
("C-z" . toggle-vterm)
("M-1" . (lambda () (interactive) (switch-vterm 1)))
("M-2" . (lambda () (interactive) (switch-vterm 2)))
("M-3" . (lambda () (interactive) (switch-vterm 3)))
@ -1943,22 +1958,7 @@
#+end_src
* Key bindings
Inspired by [[http://stackoverflow.com/questions/683425/globally-override-key-binding-in-emacs][this StackOverflow post]] I keep a =custom-bindings-map= that holds
all my custom bindings. This map can be activated by toggling a simple
=minor-mode= that does nothing more than activating the map. This inhibits
other =major-modes= to override these bindings. I keep this at the end of the
init-file to make sure that all functions are actually defined.
#+begin_src emacs-lisp
(defvar custom-bindings-map (make-keymap)
"A keymap for custom bindings.")
#+end_src
** Which key
* Which key
[[https://github.com/justbur/emacs-which-key][Which key]] is nice for discoverability.
@ -1971,7 +1971,7 @@
#+end_src
** Bindings for built-ins
* Bindings for built-ins
#+begin_src emacs-lisp
@ -1985,7 +1985,7 @@
#+end_src
** Bindings for functions defined [[sec:defuns][above]].
* Bindings for functions defined [[sec:defuns][above]].
#+begin_src emacs-lisp