Skip to content

Commit 230fbfb

Browse files
committedNov 27, 2011
Added a complete similar macro, compares the last two lines and inserts from the cursor column forward until the first difference.
1 parent 282ad07 commit 230fbfb

File tree

1 file changed

+61
-9
lines changed

1 file changed

+61
-9
lines changed
 

‎jeremy.emf

+61-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ set-variable $mode-line "%s%r%u%k %b %l:%c - %h:%m (%e) %f"
1414
set-variable $cursor-blink 250
1515
set-variable $file-ignore "~ ./ .8 .o .a .exe"
1616
set-variable $kept-version 10
17-
set-variable $tab-width 4
17+
set-variable $indent-width 4
18+
set-variable $tab-width 8
1819

1920
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2021
;
@@ -24,12 +25,62 @@ set-variable $tab-width 4
2425

2526
add-file-hook ".go" fhook-go
2627

28+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29+
;
30+
; Line handling
31+
;
32+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33+
34+
-1 global-mode "lf"
35+
2736
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2837
;
2938
; Helper Methods
3039
;
3140
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3241

42+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
43+
;
44+
; Complete what the two above lines have in common from the current cursor
45+
; position.
46+
;
47+
48+
define-macro complete-similar
49+
; #l0 is the starting column
50+
; #l1 is 2 lines back
51+
; #l2 is 1 line back
52+
; #l3 is the current length (mid string is taken from #l0 to #l3)
53+
; #l4 is the maximum length we should attempt (shorter len of #l1 and #l2)
54+
55+
set-variable #l0 $window-acol
56+
57+
2 backward-line
58+
set-variable #l1 @wl
59+
forward-line
60+
set-variable #l2 @wl
61+
forward-line
62+
63+
set-variable #l4 &len #l1
64+
!if &less &len #l2 #l4
65+
set-variable #l4 &len #l2
66+
!endif
67+
68+
set-variable #l3 1
69+
70+
!while &and &less &add #l0 &inc #l3 1 #l4 &sequal &mid #l1 #l0 #l3 &mid #l2 #l0 #l3
71+
; Loop while line 1 and line 2 strings are the same bound by #l0 and #l3
72+
; Each iteration #l3 is incremented by 1
73+
!done
74+
75+
; If we have reached the end of the string, do not deincrement by one which is
76+
; typically the failing condition from the above loop
77+
!if &not &equal &add #l0 #l3 #l4
78+
set-variable #l3 &sub #l3 1
79+
!endif
80+
81+
insert-string &mid #l1 #l0 #l3
82+
!emacro
83+
3384
; Align all subsequent lines containing #l0 to column #l1
3485
define-macro align-char
3586
set-variable .TheChar #p0
@@ -157,13 +208,13 @@ define-macro spotless
157208
; go to column 1
158209
define-macro smart-home
159210
set-variable #l0 $window-acol
160-
211+
161212
beginning-of-line
162-
213+
163214
!while &sin @wc " \t"
164215
!force forward-char
165216
!done
166-
217+
167218
!if &equal $window-acol #l0
168219
beginning-of-line
169220
!end
@@ -172,9 +223,9 @@ define-macro smart-home
172223
; Delete from the current position to the character give via the user prompt
173224
define-macro forward-delete-to
174225
ml-write "Delete to: "
175-
226+
176227
set-variable #l0 @cgk
177-
228+
178229
!if &seq #l0 "C-g"
179230
ml-write "Cancelled"
180231
!else
@@ -187,14 +238,14 @@ define-macro forward-delete-to
187238
; Delete from the current position to the character given via the user prompt
188239
define-macro backward-delete-to
189240
ml-write "Backward delete to: "
190-
241+
191242
set-variable #l0 @cgk
192-
243+
193244
!if &seq #l0 "C-g"
194245
ml-write "Cancelled"
195246
!else
196247
backward-char
197-
248+
198249
!while &not &seq @wc #l0
199250
forward-delete-char
200251
backward-char
@@ -281,3 +332,4 @@ global-bind-key next-buffer "A-right"
281332
global-bind-key smart-home "home"
282333
global-bind-key forward-delete-to "esc delete"
283334
global-bind-key backward-delete-to "esc backspace"
335+
global-bind-key complete-similar "esc space"

0 commit comments

Comments
 (0)