22
22
% %% - http://ctags.sourceforge.net/FORMAT
23
23
% %% - http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#tags-file-format
24
24
25
- % %% The Tags ets table has the following scheme:
25
+ % %% The EtsTags ets table has the following scheme:
26
26
% %%
27
27
% %% {{TagName, FilePath, Scope, Kind}, TagAddress}
28
28
% %%
@@ -317,35 +317,35 @@ add_tags_from_file(File, EtsTags, Verbose) ->
317
317
Err -> log_error (" File ~s not readable: ~p~n " , [File , Err ])
318
318
end .
319
319
320
- scan_tags (Contents , {Tags , File , ModName }) ->
320
+ scan_tags (Contents , {EtsTags , File , ModName }) ->
321
321
scan_tags_core (
322
322
Contents , ? RE_FUNCTIONS ,
323
323
fun ([_ , FuncName ]) ->
324
- add_func_tags (Tags , File , ModName , FuncName )
324
+ add_func_tags (EtsTags , File , ModName , FuncName )
325
325
end ),
326
326
scan_tags_core (
327
327
Contents , ? RE_TYPESPECS1 ,
328
328
fun ([_ , Attr , TypeName ]) ->
329
329
InnerPattern = [TypeName , " \\ >" ],
330
- add_type_tags (Tags , File , ModName , Attr , TypeName , InnerPattern )
330
+ add_type_tags (EtsTags , File , ModName , Attr , TypeName , InnerPattern )
331
331
end ),
332
332
scan_tags_core (
333
333
Contents , ? RE_TYPESPECS2 ,
334
334
fun ([_ , Attr , TypeName ]) ->
335
335
InnerPattern = [$' , TypeName , $' ],
336
- add_type_tags (Tags , File , ModName , Attr , TypeName , InnerPattern )
336
+ add_type_tags (EtsTags , File , ModName , Attr , TypeName , InnerPattern )
337
337
end ),
338
338
scan_tags_core (
339
339
Contents , ? RE_DEFINES1 ,
340
340
fun ([_ , Attr , Name ]) ->
341
341
InnerPattern = [Name , " \\ >" ],
342
- add_record_or_macro_tag (Tags , File , Attr , Name , InnerPattern )
342
+ add_record_or_macro_tag (EtsTags , File , Attr , Name , InnerPattern )
343
343
end ),
344
344
scan_tags_core (
345
345
Contents , ? RE_DEFINES2 ,
346
346
fun ([_ , Attr , Name ]) ->
347
347
InnerPattern = [$' , Name , $' ],
348
- add_record_or_macro_tag (Tags , File , Attr , Name , InnerPattern )
348
+ add_record_or_macro_tag (EtsTags , File , Attr , Name , InnerPattern )
349
349
end ),
350
350
ok .
351
351
@@ -361,37 +361,37 @@ scan_tags_core(Contents, Pattern, Fun) ->
361
361
% %% Add specific tags
362
362
% %%=============================================================================
363
363
364
- % Add this information to Tags .
365
- add_file_tag (Tags , File , BaseName , ModName ) ->
364
+ % Add this information to EtsTags .
365
+ add_file_tag (EtsTags , File , BaseName , ModName ) ->
366
366
367
367
% myfile.hrl <tab> ./myfile.hrl <tab> 1;" F
368
368
% myfile.erl <tab> ./myfile.erl <tab> 1;" F
369
369
% myfile <tab> ./myfile.erl <tab> 1;" M
370
- add_tag (Tags , BaseName , File , " 1" , global , $F ),
370
+ add_tag (EtsTags , BaseName , File , " 1" , global , $F ),
371
371
372
372
case filename :extension (File ) of
373
373
" .erl" ->
374
- add_tag (Tags , ModName , File , " 1" , global , $M );
374
+ add_tag (EtsTags , ModName , File , " 1" , global , $M );
375
375
_ ->
376
376
ok
377
377
end .
378
378
379
- % File contains the function ModName:FuncName; add this information to Tags .
380
- add_func_tags (Tags , File , ModName , FuncName ) ->
379
+ % File contains the function ModName:FuncName; add this information to EtsTags .
380
+ add_func_tags (EtsTags , File , ModName , FuncName ) ->
381
381
382
382
log (" Function definition found: ~s~n " , [FuncName ]),
383
383
384
384
% Global entry:
385
385
% mymod:f <tab> ./mymod.erl <tab> /^f\>/
386
- add_tag (Tags , [ModName , " :" , FuncName ], File , [" /^" , FuncName , " \\ >/" ],
386
+ add_tag (EtsTags , [ModName , " :" , FuncName ], File , [" /^" , FuncName , " \\ >/" ],
387
387
global , $f ),
388
388
389
389
% Static (or local) entry:
390
390
% f <tab> ./mymod.erl <tab> /^f\>/ <space><space> ;" <tab> file:
391
- add_tag (Tags , FuncName , File , [" /^" , FuncName , " \\ >/" ], local , $f ).
391
+ add_tag (EtsTags , FuncName , File , [" /^" , FuncName , " \\ >/" ], local , $f ).
392
392
393
- % File contains the type ModName:Type; add this information to Tags .
394
- add_type_tags (Tags , File , ModName , Attribute , TypeName , InnerPattern ) ->
393
+ % File contains the type ModName:Type; add this information to EtsTags .
394
+ add_type_tags (EtsTags , File , ModName , Attribute , TypeName , InnerPattern ) ->
395
395
396
396
log (" Type definition found: ~s~n " , [TypeName ]),
397
397
@@ -400,17 +400,17 @@ add_type_tags(Tags, File, ModName, Attribute, TypeName, InnerPattern) ->
400
400
% Global entry:
401
401
% mymod:mytype <tab> ./mymod.erl <tab> /^-type\s\*mytype\>/
402
402
% mymod:mytype <tab> ./mymod.erl <tab> /^-opaque\s\*mytype\>/
403
- add_tag (Tags , [ModName , " :" , TypeName ], File , Pattern , global , $t ),
403
+ add_tag (EtsTags , [ModName , " :" , TypeName ], File , Pattern , global , $t ),
404
404
405
405
% Static (or local) entry:
406
406
% mytype <tab> ./mymod.erl <tab> /^-type\s\*mytype\>/
407
407
% <space><space> ;" <tab> file:
408
408
% mytype <tab> ./mymod.erl <tab> /^-opaque\s\*mytype\>/
409
409
% <space><space> ;" <tab> file:
410
- add_tag (Tags , TypeName , File , Pattern , local , $t ).
410
+ add_tag (EtsTags , TypeName , File , Pattern , local , $t ).
411
411
412
- % File contains a macro or record called Name; add this information to Tags .
413
- add_record_or_macro_tag (Tags , File , Attribute , Name , InnerPattern ) ->
412
+ % File contains a macro or record called Name; add this information to EtsTags .
413
+ add_record_or_macro_tag (EtsTags , File , Attribute , Name , InnerPattern ) ->
414
414
415
415
{Kind , Prefix } =
416
416
case Attribute of
@@ -434,28 +434,29 @@ add_record_or_macro_tag(Tags, File, Attribute, Name, InnerPattern) ->
434
434
% myrec ./myhrl.hrl /^-record\s\*\<myrec\>/;" r
435
435
% mymac ./mymod.erl /^-define\s\*\<mymac\>/;" m file:
436
436
% mymac ./myhrl.hrl /^-define\s\*\<mymac\>/;" m
437
- add_tag (Tags , Name , File ,
437
+ add_tag (EtsTags , Name , File ,
438
438
[" /^-\\ s\\ *" , Attribute , " \\ s\\ *(\\ ?\\ s\\ *" , InnerPattern , " /" ],
439
439
Scope , Kind ),
440
440
441
441
% #myrec ./mymod.erl /^-record\s\*\<myrec\>/;" r file:
442
442
% #myrec ./myhrl.hrl /^-record\s\*\<myrec\>/;" r
443
443
% ?mymac ./mymod.erl /^-define\s\*\<mymac\>/;" m file:
444
444
% ?mymac ./myhrl.hrl /^-define\s\*\<mymac\>/;" m
445
- add_tag (Tags , [Prefix |Name ], File ,
445
+ add_tag (EtsTags , [Prefix |Name ], File ,
446
446
[" /^-\\ s\\ *" , Attribute , " \\ s\\ *(\\ ?\\ s\\ *" , InnerPattern , " /" ],
447
447
Scope , Kind ).
448
448
449
- add_tag (Tags , Tag , File , TagAddress , Scope , Kind ) ->
450
- ets :insert_new (Tags , {{Tag , File , Scope , Kind }, TagAddress }).
449
+ add_tag (EtsTags , Tag , File , TagAddress , Scope , Kind ) ->
450
+ ets :insert_new (EtsTags , {{Tag , File , Scope , Kind }, TagAddress }).
451
451
452
452
% %%=============================================================================
453
453
% %% Writing tags into a file
454
454
% %%=============================================================================
455
455
456
- tags_to_file (Tags , TagsFile ) ->
456
+ tags_to_file (EtsTags , TagsFile ) ->
457
457
Header = " !_TAG_FILE_SORTED\t 1\t /0=unsorted, 1=sorted/\n " ,
458
- Entries = lists :sort ([tag_to_binary (Entry ) || Entry <- ets :tab2list (Tags )]),
458
+ Entries = lists :sort (
459
+ [tag_to_binary (Entry ) || Entry <- ets :tab2list (EtsTags )]),
459
460
file :write_file (TagsFile , [Header , Entries ]),
460
461
ok .
461
462
@@ -475,13 +476,8 @@ tag_to_binary({{Tag, File, Scope, Kind}, TagAddress}) ->
475
476
% %% Utility functions
476
477
% %%=============================================================================
477
478
478
- % From http://www.trapexit.org/Trimming_Blanks_from_String
479
- trim (Input ) ->
480
- re :replace (Input , " \\ s*$" , " " , [{return , list }]).
481
-
482
479
log (Format ) ->
483
480
log (Format , []).
484
-
485
481
log (Format , Data ) ->
486
482
case get (verbose ) of
487
483
true ->
0 commit comments