aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMountain Man <43313373+MountainMan1312@users.noreply.github.com>2023-04-09 19:52:04 -0400
committerMountain Man <43313373+MountainMan1312@users.noreply.github.com>2023-04-09 19:52:04 -0400
commit821cd3f496503cdb7654f3faf08e06445971cfd7 (patch)
tree4bc6b1cececd9e31463fba41820b1fe3fdf25888
parentDisable backups, auto-saves, and lockfiles (diff)
downloadmmosmacs-821cd3f496503cdb7654f3faf08e06445971cfd7.tar.gz
mmosmacs-821cd3f496503cdb7654f3faf08e06445971cfd7.tar.bz2
mmosmacs-821cd3f496503cdb7654f3faf08e06445971cfd7.zip
Fix ESC key behavior
By default the ESC key has bizarre behavior. Sometimes it quits the thing you're doing, sometimes it completely removes your window layout. This fixes the issue by defining a new version of `keyboard-escape-quit` and removing the keybing for `ESC ESC`.
-rw-r--r--init.el51
1 files changed, 51 insertions, 0 deletions
diff --git a/init.el b/init.el
index 302aad5..1b2ac9d 100644
--- a/init.el
+++ b/init.el
@@ -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"))