diff options
| -rw-r--r-- | init.el | 51 |
1 files changed, 51 insertions, 0 deletions
| @@ -41,3 +41,54 @@ | |||
| 41 | ;; --------------------------------- | 41 | ;; --------------------------------- |
| 42 | 42 | ||
| 43 | (setq create-lockfiles nil) | 43 | (setq create-lockfiles nil) |
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | |||
| 48 | ;; --------------------------------------------------------------------- | ||
| 49 | ;;; Keybinds | ||
| 50 | ;; --------- | ||
| 51 | ;; For now, just a few simple changes. | ||
| 52 | ;; In the future there will be whole custom keybind system. | ||
| 53 | ;; --------------------------------------------------------------------- | ||
| 54 | |||
| 55 | ;; --------------------------------- | ||
| 56 | ;; Fix ESC behavior | ||
| 57 | ;; ---------------- | ||
| 58 | ;; The default behavior of the ESC | ||
| 59 | ;; key is atrocious. Why in God's | ||
| 60 | ;; name would I want it to close all | ||
| 61 | ;; my windows when I press it twice? | ||
| 62 | ;; | ||
| 63 | ;; This fixes the behavior to do | ||
| 64 | ;; what ESC should do: "escape" the | ||
| 65 | ;; current thing I'm doing, like the | ||
| 66 | ;; minibuffer or a popup window. | ||
| 67 | ;; --------------------------------- | ||
| 68 | |||
| 69 | ;; Define fixed version of `keyboard-escape-quit' which does not close | ||
| 70 | ;; windows or change their layout. | ||
| 71 | (defun mm/keyboard-escape-quit-keep-windows () | ||
| 72 | "Alternative version of `keyboard-escape-quit' that does not change window layout." | ||
| 73 | (interactive) | ||
| 74 | (cond ((eq last-command 'mode-exited) nil) | ||
| 75 | ((region-active-p) | ||
| 76 | (deactivate-mark)) | ||
| 77 | ((> (minibuffer-depth) 0) | ||
| 78 | (abort-recursive-edit)) | ||
| 79 | (current-prefix-arg | ||
| 80 | nil) | ||
| 81 | ((> (recursion-depth) 0) | ||
| 82 | (exit-recursive-edit)) | ||
| 83 | (buffer-quit-function | ||
| 84 | (funcall buffer-quit-function)) | ||
| 85 | ;; The following lines are from `keyboard-escape-quit'. | ||
| 86 | ;; They have been commented to disable the unwanted behavior | ||
| 87 | ;; ((not (one-window-p t)) | ||
| 88 | ;; (delete-other-windows) | ||
| 89 | ((string-match "^ \\*" (buffer-name (current-buffer))) | ||
| 90 | bury-buffer))) | ||
| 91 | |||
| 92 | ;; Fix the keybinds for the ESC key | ||
| 93 | (global-set-key (kbd "<escape>") 'mm/keyboard-escape-quit-keep-windows) | ||
| 94 | (global-unset-key (kbd "C-x ESC ESC")) | ||