-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjeremy.emf
335 lines (279 loc) · 8.41 KB
/
jeremy.emf
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
327
328
329
330
331
332
333
334
335
; -!- emf -!-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Miscelanneous Settings
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
!if &or &seq $platform "dos" &seq $platform "win32"
set-variable $home "c:/Users/Jeremy"
!endif
set-variable $mode-line "%s%r%u%k %b %l:%c - %h:%m (%e) %f"
set-variable $cursor-blink 250
set-variable $file-ignore "~ ./ .8 .o .a .exe"
set-variable $kept-version 10
set-variable $indent-width 4
set-variable $tab-width 8
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Additional file hooks
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
add-file-hook ".go" fhook-go
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Line handling
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-1 global-mode "lf"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Helper Methods
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Complete what the two above lines have in common from the current cursor
; position.
;
define-macro complete-similar
; #l0 is the starting column
; #l1 is 2 lines back
; #l2 is 1 line back
; #l3 is the current length (mid string is taken from #l0 to #l3)
; #l4 is the maximum length we should attempt (shorter len of #l1 and #l2)
set-variable #l0 $window-acol
2 backward-line
set-variable #l1 @wl
forward-line
set-variable #l2 @wl
forward-line
set-variable #l4 &len #l1
!if &less &len #l2 #l4
set-variable #l4 &len #l2
!endif
set-variable #l3 1
!while &and &less &add #l0 &inc #l3 1 #l4 &sequal &mid #l1 #l0 #l3 &mid #l2 #l0 #l3
; Loop while line 1 and line 2 strings are the same bound by #l0 and #l3
; Each iteration #l3 is incremented by 1
!done
; If we have reached the end of the string, do not deincrement by one which is
; typically the failing condition from the above loop
!if ¬ &equal &add #l0 #l3 #l4
set-variable #l3 &sub #l3 1
!endif
insert-string &mid #l1 #l0 #l3
!emacro
; Align all subsequent lines containing #l0 to column #l1
define-macro align-char
set-variable .TheChar #p0
set-variable .TheColumn #p1
*nextline
forward-line
!if &or &xsequal @wl "^[ \t]*$" &xsequal @wl "^[ \t]*//.*$"
!goto nextline
!endif
!if ¬ &xsequal @wl &cat &cat ".*" .TheChar ".*"
!goto finish
!endif
beginning-of-line
!while ¬ &sin @wc .TheChar
forward-char
!done
!if &equal .TheColumn $window-acol
!goto nextline
!endif
!if &less $window-acol .TheColumn
!while &less $window-acol .TheColumn
insert-space
!done
!goto nextline
!endif
!if &great $window-acol .TheColumn
!while &great $window-acol .TheColumn
backward-char
!if ¬ &seq @wc " "
!bell
!abort
!endif
1 forward-delete-char
!done
!goto nextline
!endif
*finish
ml-write "Finished"
!return
!emacro
; Align all subsequent lines containing the character under the cursor to the
; cursors position
define-macro align-current-char
set-variable #l0 @wc
set-variable #l1 $window-acol
align-char
!emacro
; Pad to column #l0 with spaces
define-macro pad-to-x
!while &less $window-acol #p0
insert-space
!done
!emacro
; Prompt the user for what column to pad to with spaces
define-macro pad
set-variable #l0 @ml "To Column"
pad-to-x
!emacro
; Macro to delete the whitespace, or if on a word all of the word until the
; next word is reached.
0 define-macro super-delete
set-variable #l0 0
!while ¬ &sin @wc " \t\n"
forward-char
set-variable #l0 &add #l0 1
!done
!repeat
!force forward-char
!if $status
set-variable #l0 &add #l0 1
!endif
!until &or &seq @wc "" ¬ &sin @wc " \t\n"
#l0 backward-delete-char
!return
!emacro
; Macro to backspace the whitespace, or if on a word all of the word until the
; previous word is reached.
0 define-macro super-backspace
set-variable #l0 -1
set-variable #l1 0
!repeat
!force backward-char
!if $status
set-variable #l0 &add #l0 1
!if &sin @wc " \t\n"
set-variable #l1 1
!endif
!else
set-variable #l1 1
!endif
!until #l1
!repeat
!force backward-char
!if $status
set-variable #l0 &add #l0 1
!else
&add #l0 1 forward-delete-char
!return
!endif
!until ¬ &sin @wc " \t\n"
forward-char
#l0 forward-delete-char
!return
!emacro
define-macro spotless
-1 clean
!emacro
; Go to the first non-blank character on the current line. If already there,
; go to column 1
define-macro smart-home
set-variable #l0 $window-acol
beginning-of-line
!while &sin @wc " \t"
!force forward-char
!done
!if &equal $window-acol #l0
beginning-of-line
!end
!emacro
; Delete from the current position to the character give via the user prompt
define-macro forward-delete-to
ml-write "Delete to: "
set-variable #l0 @cgk
!if &seq #l0 "C-g"
ml-write "Cancelled"
!else
!while ¬ &seq @wc #l0
forward-delete-char
!done
!end
!emacro
; Delete from the current position to the character given via the user prompt
define-macro backward-delete-to
ml-write "Backward delete to: "
set-variable #l0 @cgk
!if &seq #l0 "C-g"
ml-write "Cancelled"
!else
backward-char
!while ¬ &seq @wc #l0
forward-delete-char
backward-char
!done
!end
!emacro
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Task Timer
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; #l0 should contain the value to convert to seconds. #l0 will contain the
; result
define-macro time-to-seconds
set-variable #p0 &add &mid #p0 16 2 &mul 60 &add &mid #p0 14 2 &mul 60 &mid #p0 12 2
!emacro
; #l0 and #l1 should contain the start -> end time. #l0 will have the human
; time difference.
define-macro human-time-diff
set-variable #l0 &sub #p1 #p0 ; difference in seconds
set-variable #l1 0 ; day count
set-variable #l2 0 ; hour count
set-variable #l3 0 ; minute count
set-variable #l4 0 ; second count
!if &great #l0 86400
set-variable #l1 &div #l0 86000
set-variable #l0 &sub #l0 &mul 86000 #l1
!endif
!if &great #l0 3600
set-variable #l2 &div #l0 3600
set-variable #l0 &sub #l0 &mul 3600 #l2
!endif
!if &great #l0 60
set-variable #l3 &div #l0 60
set-variable #l0 &sub #l0 &mul 60 #l3
!endif
set-variable #l4 #l0
!if &great #l1 0
set-variable #p0 &spr "%d day %d hour %d min %d sec" #l1 #l2 #l3 #l4
!elif &great #l2 0
set-variable #p0 &spr "%d hour %d min %d sec" #l2 #l3 #l4
!elif &great #l3 0
set-variable #p0 &spr "%d min %d sec" #l3 #l4
!else
set-variable #p0 &spr "%d sec" #l4
!endif
!emacro
define-macro timer-begin
set-variable $timer-started-at $time
!emacro
define-macro timer-status
set-variable #l0 $time
time-to-seconds
set-variable #l1 #l0
set-variable #l0 $timer-started-at
time-to-seconds
human-time-diff
ml-write &spr "Elapsed time: %s" #l0
!emacro
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Key Bindings
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
global-bind-key alarm "C-c a"
global-bind-key timer-begin "C-c b"
global-bind-key timer-status "C-c s"
global-bind-key super-backspace "C-backspace"
global-bind-key super-delete "C-delete"
-1 global-bind-key next-buffer "A-left"
global-bind-key next-buffer "A-right"
global-bind-key smart-home "home"
global-bind-key forward-delete-to "esc delete"
global-bind-key backward-delete-to "esc backspace"
global-bind-key complete-similar "esc space"