Skip to content

Commit 0baf7f4

Browse files
committed
Change Tags variable name to EtsTags
1 parent 2f1f6d7 commit 0baf7f4

File tree

1 file changed

+28
-32
lines changed

1 file changed

+28
-32
lines changed

bin/vim_erlang_tags.erl

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
%%% - http://ctags.sourceforge.net/FORMAT
2323
%%% - http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#tags-file-format
2424

25-
%%% The Tags ets table has the following scheme:
25+
%%% The EtsTags ets table has the following scheme:
2626
%%%
2727
%%% {{TagName, FilePath, Scope, Kind}, TagAddress}
2828
%%%
@@ -317,35 +317,35 @@ add_tags_from_file(File, EtsTags, Verbose) ->
317317
Err -> log_error("File ~s not readable: ~p~n", [File, Err])
318318
end.
319319

320-
scan_tags(Contents, {Tags, File, ModName}) ->
320+
scan_tags(Contents, {EtsTags, File, ModName}) ->
321321
scan_tags_core(
322322
Contents, ?RE_FUNCTIONS,
323323
fun([_, FuncName]) ->
324-
add_func_tags(Tags, File, ModName, FuncName)
324+
add_func_tags(EtsTags, File, ModName, FuncName)
325325
end),
326326
scan_tags_core(
327327
Contents, ?RE_TYPESPECS1,
328328
fun([_, Attr, TypeName]) ->
329329
InnerPattern = [TypeName, "\\>"],
330-
add_type_tags(Tags, File, ModName, Attr, TypeName, InnerPattern)
330+
add_type_tags(EtsTags, File, ModName, Attr, TypeName, InnerPattern)
331331
end),
332332
scan_tags_core(
333333
Contents, ?RE_TYPESPECS2,
334334
fun([_, Attr, TypeName]) ->
335335
InnerPattern = [$', TypeName, $'],
336-
add_type_tags(Tags, File, ModName, Attr, TypeName, InnerPattern)
336+
add_type_tags(EtsTags, File, ModName, Attr, TypeName, InnerPattern)
337337
end),
338338
scan_tags_core(
339339
Contents, ?RE_DEFINES1,
340340
fun([_, Attr, Name]) ->
341341
InnerPattern = [Name, "\\>"],
342-
add_record_or_macro_tag(Tags, File, Attr, Name, InnerPattern)
342+
add_record_or_macro_tag(EtsTags, File, Attr, Name, InnerPattern)
343343
end),
344344
scan_tags_core(
345345
Contents, ?RE_DEFINES2,
346346
fun([_, Attr, Name]) ->
347347
InnerPattern = [$', Name, $'],
348-
add_record_or_macro_tag(Tags, File, Attr, Name, InnerPattern)
348+
add_record_or_macro_tag(EtsTags, File, Attr, Name, InnerPattern)
349349
end),
350350
ok.
351351

@@ -361,37 +361,37 @@ scan_tags_core(Contents, Pattern, Fun) ->
361361
%%% Add specific tags
362362
%%%=============================================================================
363363

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) ->
366366

367367
% myfile.hrl <tab> ./myfile.hrl <tab> 1;" F
368368
% myfile.erl <tab> ./myfile.erl <tab> 1;" F
369369
% 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),
371371

372372
case filename:extension(File) of
373373
".erl" ->
374-
add_tag(Tags, ModName, File, "1", global, $M);
374+
add_tag(EtsTags, ModName, File, "1", global, $M);
375375
_ ->
376376
ok
377377
end.
378378

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) ->
381381

382382
log("Function definition found: ~s~n", [FuncName]),
383383

384384
% Global entry:
385385
% mymod:f <tab> ./mymod.erl <tab> /^f\>/
386-
add_tag(Tags, [ModName, ":", FuncName], File, ["/^", FuncName, "\\>/"],
386+
add_tag(EtsTags, [ModName, ":", FuncName], File, ["/^", FuncName, "\\>/"],
387387
global, $f),
388388

389389
% Static (or local) entry:
390390
% 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).
392392

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) ->
395395

396396
log("Type definition found: ~s~n", [TypeName]),
397397

@@ -400,17 +400,17 @@ add_type_tags(Tags, File, ModName, Attribute, TypeName, InnerPattern) ->
400400
% Global entry:
401401
% mymod:mytype <tab> ./mymod.erl <tab> /^-type\s\*mytype\>/
402402
% 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),
404404

405405
% Static (or local) entry:
406406
% mytype <tab> ./mymod.erl <tab> /^-type\s\*mytype\>/
407407
% <space><space> ;" <tab> file:
408408
% mytype <tab> ./mymod.erl <tab> /^-opaque\s\*mytype\>/
409409
% <space><space> ;" <tab> file:
410-
add_tag(Tags, TypeName, File, Pattern, local, $t).
410+
add_tag(EtsTags, TypeName, File, Pattern, local, $t).
411411

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) ->
414414

415415
{Kind, Prefix} =
416416
case Attribute of
@@ -434,28 +434,29 @@ add_record_or_macro_tag(Tags, File, Attribute, Name, InnerPattern) ->
434434
% myrec ./myhrl.hrl /^-record\s\*\<myrec\>/;" r
435435
% mymac ./mymod.erl /^-define\s\*\<mymac\>/;" m file:
436436
% mymac ./myhrl.hrl /^-define\s\*\<mymac\>/;" m
437-
add_tag(Tags, Name, File,
437+
add_tag(EtsTags, Name, File,
438438
["/^-\\s\\*", Attribute, "\\s\\*(\\?\\s\\*", InnerPattern, "/"],
439439
Scope, Kind),
440440

441441
% #myrec ./mymod.erl /^-record\s\*\<myrec\>/;" r file:
442442
% #myrec ./myhrl.hrl /^-record\s\*\<myrec\>/;" r
443443
% ?mymac ./mymod.erl /^-define\s\*\<mymac\>/;" m file:
444444
% ?mymac ./myhrl.hrl /^-define\s\*\<mymac\>/;" m
445-
add_tag(Tags, [Prefix|Name], File,
445+
add_tag(EtsTags, [Prefix|Name], File,
446446
["/^-\\s\\*", Attribute, "\\s\\*(\\?\\s\\*", InnerPattern, "/"],
447447
Scope, Kind).
448448

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}).
451451

452452
%%%=============================================================================
453453
%%% Writing tags into a file
454454
%%%=============================================================================
455455

456-
tags_to_file(Tags, TagsFile) ->
456+
tags_to_file(EtsTags, TagsFile) ->
457457
Header = "!_TAG_FILE_SORTED\t1\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)]),
459460
file:write_file(TagsFile, [Header, Entries]),
460461
ok.
461462

@@ -475,13 +476,8 @@ tag_to_binary({{Tag, File, Scope, Kind}, TagAddress}) ->
475476
%%% Utility functions
476477
%%%=============================================================================
477478

478-
% From http://www.trapexit.org/Trimming_Blanks_from_String
479-
trim(Input) ->
480-
re:replace(Input, "\\s*$", "", [{return, list}]).
481-
482479
log(Format) ->
483480
log(Format, []).
484-
485481
log(Format, Data) ->
486482
case get(verbose) of
487483
true ->

0 commit comments

Comments
 (0)