mirror of
https://github.com/larstvei/dot-emacs.git
synced 2024-11-26 07:28:31 +00:00
Use the custom-bindings-map
This commit is contained in:
parent
ecbdf40171
commit
e9d6556bf1
64
init.org
64
init.org
@ -310,6 +310,20 @@
|
|||||||
|
|
||||||
#+end_src
|
#+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
|
* Modal meow
|
||||||
|
|
||||||
I have been wanting to try out modal editing. [[https://github.com/meow-edit/meow][meow]] seems like a nice package,
|
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
|
;; Minor mode for a nice writing environment
|
||||||
(use-package olivetti
|
(use-package olivetti
|
||||||
:defer t
|
:defer t
|
||||||
:bind ("C-c o" . olivetti-mode)
|
:bind (:map custom-bindings-map ("C-c o" . olivetti-mode))
|
||||||
:config
|
:config
|
||||||
(setq-default olivetti-body-width (+ fill-column 3))
|
(setq-default olivetti-body-width (+ fill-column 3))
|
||||||
(remove-hook 'olivetti-mode-on-hook 'visual-line-mode))
|
(remove-hook 'olivetti-mode-on-hook 'visual-line-mode))
|
||||||
@ -580,7 +594,7 @@
|
|||||||
;; Dim color of text in surrounding sections
|
;; Dim color of text in surrounding sections
|
||||||
(use-package focus
|
(use-package focus
|
||||||
:defer t
|
:defer t
|
||||||
:bind ("C-c f" . focus-mode))
|
:bind (:map custom-bindings-map ("C-c f" . focus-mode)))
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -686,7 +700,7 @@
|
|||||||
|
|
||||||
;; A Git porcelain inside Emacs.
|
;; A Git porcelain inside Emacs.
|
||||||
(use-package magit
|
(use-package magit
|
||||||
:bind ("C-c m" . magit-status))
|
:bind (:map custom-bindings-map ("C-c m" . magit-status)))
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -722,7 +736,7 @@
|
|||||||
|
|
||||||
;; Manage and navigate projects in Emacs easily
|
;; Manage and navigate projects in Emacs easily
|
||||||
(use-package projectile
|
(use-package projectile
|
||||||
:bind ("C-c p" . projectile-command-map))
|
:bind (:map custom-bindings-map ("C-c p" . projectile-command-map)))
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -738,7 +752,7 @@
|
|||||||
|
|
||||||
;; Incremental Vertical completion
|
;; Incremental Vertical completion
|
||||||
(use-package ivy
|
(use-package ivy
|
||||||
:bind ("C-x b" . ivy-switch-buffer)
|
:bind (:map custom-bindings-map ("C-x b" . ivy-switch-buffer))
|
||||||
:config
|
:config
|
||||||
(setq ivy-wrap t ; Easier access to the last candidate
|
(setq ivy-wrap t ; Easier access to the last candidate
|
||||||
ivy-height 25 ; Give me more candidates to look at
|
ivy-height 25 ; Give me more candidates to look at
|
||||||
@ -766,14 +780,13 @@
|
|||||||
Use counsel for =M-x=, yanking and finding files.
|
Use counsel for =M-x=, yanking and finding files.
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
|
||||||
;; Various completion functions using Ivy
|
;; Various completion functions using Ivy
|
||||||
(use-package counsel
|
(use-package counsel
|
||||||
:bind
|
:bind
|
||||||
(("M-x" . counsel-M-x)
|
(:map custom-bindings-map
|
||||||
|
("M-x" . counsel-M-x)
|
||||||
("M-y" . counsel-yank-pop)
|
("M-y" . counsel-yank-pop)
|
||||||
("C-x C-f" . counsel-find-file)))
|
("C-x C-f" . counsel-find-file)))
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Use swiper for fancy search.
|
Use swiper for fancy search.
|
||||||
@ -782,7 +795,7 @@
|
|||||||
|
|
||||||
;; Isearch with an overview. Oh, man!
|
;; Isearch with an overview. Oh, man!
|
||||||
(use-package swiper
|
(use-package swiper
|
||||||
:bind ("C-c i" . swiper-isearch))
|
:bind (:map custom-bindings-map ("C-c i" . swiper-isearch)))
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -916,7 +929,7 @@
|
|||||||
;; display the definition of word at point
|
;; display the definition of word at point
|
||||||
(use-package define-word
|
(use-package define-word
|
||||||
:defer t
|
:defer t
|
||||||
:bind ("C-c D" . define-word-at-point))
|
:bind (:map custom-bindings-map ("C-c D" . define-word-at-point)))
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -1162,7 +1175,7 @@
|
|||||||
(executable-find "mbsync")
|
(executable-find "mbsync")
|
||||||
(executable-find "msmtp")
|
(executable-find "msmtp")
|
||||||
(executable-find "mu"))
|
(executable-find "mu"))
|
||||||
:bind ("C-x m" . mu4e)
|
:bind (:map custom-bindings-map ("C-x m" . mu4e))
|
||||||
:config
|
:config
|
||||||
(setq
|
(setq
|
||||||
mail-user-agent 'mu4e-user-agent
|
mail-user-agent 'mu4e-user-agent
|
||||||
@ -1230,7 +1243,8 @@
|
|||||||
;; Multiple cursors for Emacs
|
;; Multiple cursors for Emacs
|
||||||
(use-package multiple-cursors
|
(use-package multiple-cursors
|
||||||
:defer t
|
: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 a" . mc/mark-all-like-this)
|
||||||
("C-c n" . mc/mark-next-like-this)))
|
("C-c n" . mc/mark-next-like-this)))
|
||||||
|
|
||||||
@ -1245,7 +1259,7 @@
|
|||||||
;; Increase selected region by semantic units
|
;; Increase selected region by semantic units
|
||||||
(use-package expand-region
|
(use-package expand-region
|
||||||
:defer t
|
:defer t
|
||||||
:bind ("C-=" . er/expand-region))
|
:bind (:map custom-bindings-map ("C-=" . er/expand-region)))
|
||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
@ -1546,7 +1560,8 @@
|
|||||||
(t (vterm buffer-name)
|
(t (vterm buffer-name)
|
||||||
(rename-buffer 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-1" . (lambda () (interactive) (switch-vterm 1)))
|
||||||
("M-2" . (lambda () (interactive) (switch-vterm 2)))
|
("M-2" . (lambda () (interactive) (switch-vterm 2)))
|
||||||
("M-3" . (lambda () (interactive) (switch-vterm 3)))
|
("M-3" . (lambda () (interactive) (switch-vterm 3)))
|
||||||
@ -1943,22 +1958,7 @@
|
|||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
* Key bindings
|
* Which key
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
[[https://github.com/justbur/emacs-which-key][Which key]] is nice for discoverability.
|
[[https://github.com/justbur/emacs-which-key][Which key]] is nice for discoverability.
|
||||||
|
|
||||||
@ -1971,7 +1971,7 @@
|
|||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Bindings for built-ins
|
* Bindings for built-ins
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
|
||||||
@ -1985,7 +1985,7 @@
|
|||||||
|
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Bindings for functions defined [[sec:defuns][above]].
|
* Bindings for functions defined [[sec:defuns][above]].
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user