Commit 2b6b45221810

Vincent Demeester <vincent@sbr.pm>
2020-01-31 15:03:00
emacs.org: add setup-keybindings.el
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 5110bf3
Changed files (2)
lisp/setup-keybindings.el
@@ -1,7 +1,3 @@
-;;; setup-keybindings.el --- setup keybindings 👼 -*- lexical-binding: t; -*-
-;;; Commentary:
-;;; Code:
-
 (use-package which-key
   :init (which-key-mode)
   :custom
@@ -43,8 +39,3 @@
 (unbind-key "C-x C-n" global-map)
 
 (provide 'setup-keybindings)
-
-;; Local Variables:
-;; coding: utf-8
-;; indent-tabs-mode: nil
-;; End:
emacs.org
@@ -1717,6 +1717,55 @@
   (provide 'setup-hydras)
 #+end_src
 
+*** ~setup-keybindings.el~
+:PROPERTIES:
+:CUSTOM_ID: h:9b69d5a9-f589-4348-9798-7a03c850fcbc
+:END:
+
+#+begin_src emacs-lisp :tangle lisp/setup-keybindings.el
+  (use-package which-key
+    :init (which-key-mode)
+    :custom
+    (which-key-idle-delay 2)
+    (which-key-idle-secondary-delay 0.05)
+    (which-key-show-early-on-C-h t)
+    (which-key-sort-order 'which-key-prefix-then-key-order)
+    (which-key-popup-type 'side-window)
+    (which-key-show-prefix 'echo)
+    (which-key-max-display-columns 6)
+    (which-key-separator " → ")
+    :config
+    (add-to-list 'which-key-replacement-alist '(("TAB" . nil) . ("↹" . nil)))
+    (add-to-list 'which-key-replacement-alist '(("RET" . nil) . ("⏎" . nil)))
+    (add-to-list 'which-key-replacement-alist '(("DEL" . nil) . ("⇤" . nil)))
+    (add-to-list 'which-key-replacement-alist '(("SPC" . nil) . ("␣" . nil))))
+
+  (use-package region-bindings-mode
+    :config
+    ;; Do not activate `region-bindings-mode' in Special modes like `dired' and
+    ;; `ibuffer'. Single-key bindings like 'm' are useful in those modes even
+    ;; when a region is selected.
+    (setq region-bindings-mode-disabled-modes '(dired-mode ibuffer-mode))
+
+    (region-bindings-mode-enable)
+
+    (defun vde/disable-rbm-deactivate-mark ()
+      "Disable `region-bindings-mode' and deactivate mark."
+      (interactive)
+      (region-bindings-mode -1)
+      (deactivate-mark)
+      (message "Mark deactivated"))
+
+    (bind-keys
+     :map region-bindings-mode-map
+     ("<C-SPC>" . vde/disable-rbm-deactivate-mark)))
+
+  ;; Disable C-x C-n to avoid the disabled command buffer
+  (unbind-key "C-x C-n" global-map)
+
+  (provide 'setup-keybindings)
+#+end_src
+
 *** ~setup-navigating.el~
 :PROPERTIES:
 :CUSTOM_ID: h:c5ec18c7-1153-451c-b472-33b55f1bba77