-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhich.rc
282 lines (271 loc) · 6.49 KB
/
which.rc
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
;; $Header: /usr/build/vile/vile/macros/RCS/which.rc,v 1.19 2008/11/07 00:21:28 tom Exp $
;;
;; Show where vile looks for keyword file, and where it finds it. If we
;; always implemented built-in filters, the natural place for this would be
;; within filters/filters.c - and no need for a macro. But we may have
;; configured with external filters. Rather than maintain two chunks of
;; similar C code, this is implemented as a macro (as an exercise ;-).
store-procedure WhichFilename f='Filename'
~local %flag %attr %len %full %view
newline
~if &rd $1
insert-string '* '
setv %found="yes"
~if &stoken 'hypertext' ',' $cfgopts
setv %full=&pquote &path full $1
~if &seq $os "win32"
setv %full=&translate '\' '/' %full
~endif
setv %len=&len $1
setv %view=&cat 'Hview ' %full
setv %attr=&cat &chr 1 %len
insert-string %attr
insert-string %view
insert-number 0
insert-string 'R:'
~endif
~else
insert-string ' '
~endif
insert-string $1
~endm
store-procedure which-filter major="MajorMode" "Prompt for, and display location of filter program"
~if &seq '' $1
~return
~endif
~local $autocolor $majormode
~local %mybuffer %filtername %long %short %path %index %found
setv %long=$1
setv %short=&left $1 &sub &len $1 4
setv %mybuffer='[Which Filter]'
~if &isa buffer %mybuffer
~force select-buffer %mybuffer
setl noreadonly noview
~if &greater $bchars 0
goto-beginning-of-file
delete-lines-til end-of-file
~endif
~else
edit-buffer %mybuffer
setl noreadonly noview
~endif
setl noai
; turn off autocolor
set autocolor=0
; set the majormode so we can see what the filtername is
~hidden setl %long
; filtername is set only when it is not the default for the mode.
; Capture a copy of its value, which may be ERROR.
setv %filtername=$filtername
~hidden unsetl %long
; If $filtername was not set, we can still make a good guess.
~if &error %filtername
setv %filtername=&cat 'vile-' &cat %short '-filt'
~elseif &seq %filtername ''
setv %filtername=&cat 'vile-' &cat %short '-filt'
~else
setv %filtername=&cat &word 0 %filtername
~endif
setv %filtername=&cat %filtername $exec-suffix
;
insert-string 'Show which filter-files are tested for:'
newline
insert-string &cat &chr 9 %long
newline
insert-string '(* marks found-files)'
2 newline
;
insert-string '$PATH'
setv %index=0
~while true
setv %path=&token %index $pathlist-separator &env 'PATH'
~if &seq %path ''
~break
~endif
WhichFilename &pcat %path %filtername
setv %index=&add %index 1
~endwhile
;
newline
insert-string '$cwd'
WhichFilename %filtername
;
newline
insert-string '$libdir-path'
setv %index=0
~while true
setv %path=&token %index $pathlist-separator $libdir-path
~if &seq %path ''
~break
~endif
WhichFilename &pcat %path %filtername
setv %index=&add %index 1
~endwhile
;
~if &stoken 'hypertext' ',' $cfgopts
1 goto-line
attribute-cntl_a-sequences-til end-of-file
~endif
unmark-buffer
setl readonly view
goto-beginning-of-file
~if &filter %short
write-message &cat 'Filter for ' &cat %long ' is built-in'
~else
write-message &cat 'Filter name: ' %filtername
~endif
~endm
store-procedure which-keywords major="MajorMode" "Prompt for, and display location of keyword files"
~if &seq '' $1
~return
~endif
~local %path %leaf %suffix %pathdot %dothides %index %mybuffer %found %long %short
setv %found="no"
~local $report $terse
setv $report=0
set terse
setv %long=$1
setv %short=&left $1 &sub &len $1 4
;
setv %mybuffer='[Which Keywords]'
~force select-buffer %mybuffer
~if $status
setl noreadonly noview
~if &greater $bchars 0
goto-beginning-of-file
delete-lines-til end-of-file
~endif
~else
edit-buffer %mybuffer
setl noreadonly noview
~endif
setl noai
;
insert-string 'Show which keyword-files are tested for:'
newline
insert-string &cat &chr 9 %long
newline
insert-string '(* marks found-files)'
2 newline
;
setv %suffix='.keywords'
~if &seq $os "win32"
setv %dothides=''
setv %pathdot='.'
~elseif &seq $os "vms"
setv %dothides=''
setv %pathdot='[]'
~else
setv %dothides='.'
setv %pathdot='.'
~endif
;
setv %leaf=&cat %short %suffix
insert-string '$cwd'
WhichFilename &pcat %pathdot &cat %dothides %leaf
;
newline
insert-string '$HOME'
WhichFilename &pcat '~' &cat %dothides %leaf
WhichFilename &pcat '~' &cat %dothides &pcat 'vile' %leaf
;
newline
insert-string '$startup-path'
setv %index=0
~while true
setv %path=&token %index $pathlist-separator $startup-path
~if &seq %path ''
~break
~endif
WhichFilename &pcat %path %leaf
setv %index=&add %index 1
~endwhile
;
~if &stoken 'hypertext' ',' $cfgopts
1 goto-line
attribute-cntl_a-sequences-til end-of-file
~endif
unmark-buffer
setl readonly view
goto-beginning-of-file
~endm
~if &seq $progname "xvile"
store-procedure which-menu "Display location of menu file"
~local %path %leaf %suffix %pathdot %dothides %index %mybuffer %found %dotname
setv %found="no"
~local $report $terse
set report=0
set terse
;
setv %mybuffer='[Which Menufile]'
~force select-buffer %mybuffer
~if $status
setl noreadonly noview
~if &greater $bchars 0
goto-beginning-of-file
delete-lines-til end-of-file
~endif
~else
edit-buffer %mybuffer
setl noreadonly noview
~endif
setl noai
;
insert-string 'Show which menu-files are tested for:'
newline
insert-string &cat &chr 9 $menu-file
newline
insert-string '(* marks found-files)'
2 newline
;
~if &seq $os "win32"
setv %dothides=''
setv %pathdot='.'
~elseif &seq $os "vms"
setv %dothides=''
setv %pathdot='[]'
~else
setv %dothides='.'
setv %pathdot='.'
~endif
;
; Look for $menu-file in the current and home-directories
setv %leaf=$menu-file
insert-string '$cwd'
WhichFilename &pcat %pathdot %leaf
;
newline
insert-string '$HOME'
WhichFilename &pcat '~' %leaf
;
; If dot hides a name, and $menu-file begins with a dot, we are done
; with it. Use "vilemenu.rc" in the other places. If it does not
; begin with a dot, continue using it.
setv %dotname &left %leaf 1
~if &and \
&seq %dothides '.' \
&seq %dotname '.'
setv %leaf='vilemenu.rc'
~endif
;
newline
insert-string '$startup-path'
setv %index=0
~while true
setv %path=&token %index $pathlist-separator $startup-path
~if &seq %path ''
~break
~endif
WhichFilename &pcat %path %leaf
setv %index=&add %index 1
~endwhile
;
~if &stoken 'hypertext' ',' $cfgopts
1 goto-line
attribute-cntl_a-sequences-til end-of-file
~endif
unmark-buffer
setl readonly view
goto-beginning-of-file
~endm
~endif