-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmacsEverywhere.ahk
326 lines (303 loc) · 7.38 KB
/
EmacsEverywhere.ahk
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
; >>> transpose characters Emacs style <<<<
; using Ctrl+q as Ctrl+t is used for a bunch of things already 'New tab' etc
<^q::
SetTitleMatchMode, 2
IfWinActive, - Microsoft Outlook ; Escaping this shortcut for Microsoft Outlook
{
Send, ^q ; marks email as read
} else{
; save the old clipboard
ClipboardOld := ClipboardAll
Send, +{right}
Send, ^x
Send, {right}
Send, ^v
; Restore the old clipboard
Clipboard := ClipboardOld
ClipboardOld := ""
}
return
}
return
;>>>>>>>>>>>>>>>>>>> Multiclipboard handling functionality <<<<<<<<<<<<<<
;>>>>>>>>>>>>>>>>>>>>>> EMACS kill ring <<<<<<<<<<<<<<<<<<<<<<<<
handleClip(action)
{
global static AddNextNum
global static GetNextNum
global static HighestNum
global static getprevnum
global static ClipArray
global static ClipArray1
global static ClipArray2
global static ClipArray3
global static ClipArray4
global static ClipArray5
global static ClipArray6
global static ClipArray7
global static ClipArray8
global static ClipArray9
global static ClipArray10
; Increase the number of clip array objects if you want a longer kill ring
if (action = "save")
{
if (AddNextNum < 10) ; increase this for a longer kill ring
{
AddNextNum += 1 ;
}
else
{
AddNextNum := 1 ;
}
if (HighestNum < 10) ; increase this for a longer kill ring
{
HighestNum += 1 ;
}
GetNextNum := AddNextNum ;
ClipArray%AddNextNum% := Clipboard
highest1 := highestnum + 1
getprevnum := 1
}
else if ((action = "get") OR (action = "roll"))
{
if (GetNextNum != 0)
{
if (action = "roll")
{
Send, ^z
}
Clipboard := ClipArray%GetNextNum%
if (GetNextNum > 1)
{
GetNextNum -= 1 ;
getprevnum++
}
else
{
getprevnum := 1
GetNextNum := HighestNum
}
Send, ^v
}
}
else if (action = "get-reverse")
{
if (GetNextNum != 0)
{
Clipboard := ClipArray%getprevnum%
if (GetNextNum > 1)
{
GetNextNum -= 1 ;
getprevnum++
}
else
{
getprevnum := 1
GetNextNum := HighestNum
}
Send, ^v
}
}
else if (action = "rollforward")
{
if (GetNextNum != 0)
{
Send, ^z
if (GetNextNum < HighestNum)
{
GetNextNum += 1 ;
}
else
{
GetNextNum := 1
}
Clipboard := ClipArray%GetNextNum%
Send, ^v
}
}
else if (action = "clear")
{
GetNextNum := 0
AddNextNum := 0
HighestNum := 0
getprevnum := 0
Loop, 30
{
ClipArray%A_Index% :=
}
MsgBox, ClipboardQueue Cleared!
}
}
;===================end of main area ========
; Keyboard shortcuts follow
#0::
handleClip("clear")
return
; over-writing Ctrl+C for copy shortcut to add kill-ring functionality
^c::
suspend on
Send, ^c
suspend off
handleClip("save")
return
; Shortcuts for pasting Windows Key + V to paste the recent copy, pressing again will get the older one in the stack
#v::
handleClip("get")
return
; Ctrl + Windows Key + V - Pastes the last item in the Kill-ring stack (bottom most)
^#v::
handleClip("get-reverse")
return
; Windows Key + \ -> pastes the most recent item from the kill rings stack and repeatedly pressing this will
; cycle through all the different items in the stack
#\::
handleClip("roll")
return
; Ctrl + Windows Key + \ -> pastes the last item from the kill rings stack and repeatedly pressing this will
; cycle through all the different items in the stack
#^\::
handleClip("rollforward")
return
;>>>>>>>>>>>>>>>>>>>>>>>>>>> EMACS Style Select till end of sentence <<<<<<<<<<<<<<<<<<<<
; Left Alt + / -> Selects from current cursor position till it encounters a '/' or 15 words whichever comes first
<!/::
ClipboardOld := ClipboardAll
Clipboard := ""
InsertPoint := 0
InsertPoint2 := 0
ClipboardFirst := ""
Length := 0
Loop
{
Send, ^+{Right}
A_Index2 := A_Index
Send, ^c
Sleep, 20
Length := StrLen(Clipboard)
InsertPoint := RegExMatch(Clipboard,"[\\\/]")
;MsgBox, InsertPoint %InsertPoint% ; for debugging
If (InsertPoint = 0)
{
If (A_Index2 >= 15)
{
break
}
continue
}
else
{
break
}
}
; Since we may overshoot the . or other special character by use of Ctrl + -> in Windows
; we have to Shift + <- back by how much we overshot
If(InsertPoint > 0 && InsertPoint <> Length)
{
GoLeftBy := Length - InsertPoint
Loop %GoLeftBy%
{
Send, +{Left}
}
}
Clipboard := ClipboardOld
ClipboardOld := ""
return
; Left Alt + ' -> Selects from current cursor position till it encounters a single quote ' or double " or 15 words whichever comes first
<!'::
ClipboardOld := ClipboardAll
Clipboard := ""
InsertPoint := 0
InsertPoint2 := 0
ClipboardFirst := ""
Length := 0
Loop
{
Send, ^+{Right}
A_Index2 := A_Index
Send, ^c
Sleep, 20
Length := StrLen(Clipboard)
InsertPoint := RegExMatch(Clipboard,"[""\']")
;MsgBox, InsertPoint %InsertPoint% ; for debugging
If (InsertPoint = 0)
{
If (A_Index2 >= 15)
{
break
}
continue
}
else
{
break
}
}
; Since we may overshoot the . or other special character by use of Ctrl + -> in Windows
; we have to Shift + <- back by how much we overshot
If(InsertPoint > 0 && InsertPoint <> Length)
{
GoLeftBy := Length - InsertPoint
Loop %GoLeftBy%
{
Send, +{Left}
}
}
Clipboard := ClipboardOld
ClipboardOld := ""
return
; Left Alt + . -> Selects from current cursor position till it encounters a period '.' (i.e. end of sentence) or 15 words whichever comes first
<!.::
ClipboardOld := ClipboardAll
Clipboard := ""
InsertPoint := 0
InsertPoint2 := 0
ClipboardFirst := ""
Length := 0
Loop
{
Send, ^+{Right}
A_Index2 := A_Index
Send, ^c
Sleep, 20
Length := StrLen(Clipboard)
InsertPoint := RegExMatch(Clipboard,"[\.]")
;MsgBox, InsertPoint %InsertPoint% ; for debugging
If (InsertPoint = 0)
{
If (A_Index2 >= 15)
{
break
}
continue
}
else
{
break
}
}
; Since we may overshoot the . or other special character by use of Ctrl + -> in Windows
; we have to Shift + <- back by how much we overshot
If(InsertPoint > 0 && InsertPoint <> Length)
{
GoLeftBy := Length - InsertPoint
Loop %GoLeftBy%
{
Send, +{Left}
}
}
Clipboard := ClipboardOld
ClipboardOld := ""
return
; >>>>>>>>>> Mac style cycle/switch through windows of current application
;(i.e. Win equivalent of Macs -> Cmd+` <<<<
; Left Alt + ` (Backtick)
<!`:: ; Next window
WinGetClass, ActiveClass, A
WinSet, Bottom,, A
WinActivate, ahk_class %ActiveClass%
return
; Ctrl + Left Alt + ` (Backtick)
<!^`:: ; Last window
WinGetClass, ActiveClass, A
WinActivateBottom, ahk_class %ActiveClass%
return