-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandy-mode-modal.el
152 lines (120 loc) · 3.23 KB
/
handy-mode-modal.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
;; handy-mode
;; Copyright (C) 2019 David Capello
(require 'edmacro)
;; Default state is normal (where keystrokes insert chars)
(defvar handy-state 'normal)
(defun handy-switch-state ()
(interactive)
(if (eq handy-state 'normal)
(progn
;; Enable Alt+locked mode
(message "ALT-LOCKED HANDY-MODE")
(setq handy-state 'locked)
(handy-mode-locked-state 1))
;; Disable Alt+locked mode
(message "normal handy-mode")
(setq handy-state 'normal)
(handy-mode-locked-state 0)))
(defvar handy-mode-modal-map
(handy-make-keymap
"M-p" 'handy-switch-state))
(defvar handy-mode-locked-map
;; TODO remove the duplication of all keys, iterate all keymaps and
;; create the map without the M- prefix here
(handy-make-keymap
;; jlik
"j" 'backward-char
"l" 'forward-char
"i" 'previous-line
"k" 'next-line
"J" 'backward-sexp
"L" 'forward-sexp
"I" 'scroll-down-command
"K" 'scroll-up-command
;; nm
"n" 'handy-keyboard-quit
"M" 'execute-extended-command
"m 1" 'delete-other-windows
"m 2" 'split-window-vertically
"m M-2" 'split-window-horizontally
"m 3" 'handy-three-windows
"m TAB" 'handy-next-window
"m <backtab>" 'handy-previous-window
"N" 'handy-new-file
"m s" 'save-buffer
"m d" 'ido-dired
"m f" 'find-file
"m g" 'goto-line
"m M-s" 'save-some-buffers
"m M-f" 'projectile-find-file
"m M-g" 'grep-find
"m l" 'kmacro-end-and-call-macro
"m j" 'handy-switch-macro-editing
"m i" 'bookmark-jump
"m k" 'bookmark-set
"m b" 'bookmark-bmenu-list
"m M-i" 'jump-to-register
"m M-k" 'point-to-register
"m M-c" 'copy-to-register
"m M-v" 'insert-register
"m M-b" 'list-registers
"m M-SPC" 'mark-paragraph
"m a" 'sort-lines
"m c" 'handy-change-case
"m t" 'transpose-chars
"m M-t" 'transpose-words
"m M-T" 'transpose-sexps
"m h" 'back-to-indentation
"m M-l" 'handy-indent
"m M-e" 'handy-eshell
"m M-m" 'handy-compile
"m M-u" 'previous-error
"m M-o" 'next-error
;; uo
"u" 'backward-word
"o" 'forward-word
"U" 'handy-beginning-of-block
"O" 'handy-end-of-block
;; zb
"z" 'handy-undo
"Z" 'handy-redo
"x" 'handy-cut
"c" 'handy-copy
"C" 'handy-copy-all
"v" 'handy-paste
"V" 'handy-paste-rotate
"b" 'ido-switch-buffer
"B" 'ibuffer
"SPC" 'handy-set-mark
"S-SPC" 'mark-sexp
;; yh
"h" 'handy-beginning-of-line-and-buffer
"H" 'handy-end-of-line-and-buffer
"y" 'isearch-forward ; replaces yank
"Y" 'isearch-backward ; replaces yank
;; werd
"w" 'handy-shrink-whitespace
"e" 'backward-kill-word
"r" 'kill-word
"d" 'delete-backward-char
"f" 'delete-char
"g" 'kill-line
"W" 'handy-close-file
"D" 'backward-kill-sexp
"F" 'kill-sexp
"G" 'handy-backward-kill-line
))
(define-key handy-mode-locked-map [remap self-insert-command] 'ignore)
(define-minor-mode handy-mode-modal
"Enables the modal handy-mode.
M-p : `handy-switch-state'
"
:global t
:group 'handy-mode
:keymap handy-mode-modal-map)
(define-minor-mode handy-mode-locked-state
"It is the Alt+locked state of modal handy-mode."
:global t
:group 'handy-mode
:lighter "+ALT"
:keymap handy-mode-locked-map)