Skip to content

Commit d31be3c

Browse files
committed
support for tcgrep included
1 parent 963f2ee commit d31be3c

File tree

2 files changed

+688
-19
lines changed

2 files changed

+688
-19
lines changed

plugin/grep.vim

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,36 @@
6969
" :Ragrep - Run recursive agrep
7070
" :RagrepAdd - Same as ":Ragrep" but adds the results to the current
7171
" results
72+
" :Tcgrep - Run tcgrep
73+
" :TcgrepAdd - Same as ":Tcgrep" but adds the results to the current
74+
" results
75+
" :Rtcgrep - Run recursive tcgrep
76+
" :RtcgrepAdd - Same as ":Rtcgrep" but adds the results to the current
77+
" results
7278
"
7379
" The above commands can be invoked like this:
7480
"
75-
" :Grep [<grep_options>] [<search_pattern> [<file_name(s)>]]
76-
" :Rgrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
77-
" :Fgrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
78-
" :Rfgrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
79-
" :Egrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
80-
" :Regrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
81-
" :Agrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
82-
" :Ragrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
83-
"
84-
" :GrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
85-
" :RgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
86-
" :FgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
87-
" :RfgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
88-
" :EgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
89-
" :RegrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
90-
" :AgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
91-
" :RagrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
81+
" :Grep [<grep_options>] [<search_pattern> [<file_name(s)>]]
82+
" :Rgrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
83+
" :Fgrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
84+
" :Rfgrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
85+
" :Egrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
86+
" :Regrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
87+
" :Agrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
88+
" :Ragrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
89+
" :Tcgrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
90+
" :Rtcgrep [<grep_options>] [<search_pattern> [<file_name(s)>]]
91+
"
92+
" :GrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
93+
" :RgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
94+
" :FgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
95+
" :RfgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
96+
" :EgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
97+
" :RegrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
98+
" :AgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
99+
" :RagrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
100+
" :TcgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
101+
" :RtcgrepAdd [<grep_options>] [<search_pattern> [<file_name(s)>]]
92102
"
93103
" :GrepBuffer [<grep_options>] [<search_pattern>]
94104
" :Bgrep [<grep_options>] [<search_pattern>]
@@ -196,6 +206,11 @@
196206
"
197207
" :let Agrep_Path = 'd:\tools\agrep.exe'
198208
"
209+
" The 'Tcgrep_Path' variable is used to locate the tcgrep utility. By default,
210+
" this is set to tcgrep. You can change this using the let command:
211+
"
212+
" :let Tcgrep_Path = 'd:\tools\tcgrep.pl'
213+
"
199214
" The 'Grep_Find_Path' variable is used to locate the find utility. By
200215
" default, this is set to 'find'. Note that on MS-Windows, there is a find.exe
201216
" that is part of the base OS. This find utility is different from the the
@@ -321,6 +336,13 @@ if !exists("Agrep_Path")
321336
let Agrep_Path = 'agrep'
322337
endif
323338

339+
" Location of the tcgrep utility
340+
if !exists("Tcgrep_Path")
341+
let Tcgrep_Path = '$VIM/vimfiles/tools/tcgrep.pl'
342+
endif
343+
344+
let Tcgrep_Path = 'perl "' . expand(Tcgrep_Path, ":p"). '"'
345+
324346
" Location of the find utility
325347
if !exists("Grep_Find_Path")
326348
let Grep_Find_Path = 'find'
@@ -518,7 +540,11 @@ function! s:RunGrepRecursive(cmd_name, grep_cmd, action, ...)
518540
if a:grep_cmd != 'agrep'
519541
" Don't display messages about non-existent files
520542
" Agrep doesn't support the -s option
521-
let grep_opt = grep_opt . " -s"
543+
if a:grep_cmd != 'tcgrep'
544+
let grep_opt = grep_opt . " -s"
545+
else
546+
let grep_opt = grep_opt . " -q"
547+
endif
522548
endif
523549

524550
if a:grep_cmd == 'grep'
@@ -533,6 +559,9 @@ function! s:RunGrepRecursive(cmd_name, grep_cmd, action, ...)
533559
elseif a:grep_cmd == 'agrep'
534560
let grep_path = g:Agrep_Path
535561
let grep_expr_option = ''
562+
elseif a:grep_cmd == 'tcgrep'
563+
let grep_path = g:Tcgrep_Path
564+
let grep_expr_option = ''
536565
else
537566
return
538567
endif
@@ -787,7 +816,11 @@ function! s:RunGrep(cmd_name, grep_cmd, action, ...)
787816
if a:grep_cmd != 'agrep'
788817
" Don't display messages about non-existent files
789818
" Agrep doesn't support the -s option
790-
let grep_opt = grep_opt . " -s"
819+
if a:grep_cmd != 'tcgrep'
820+
let grep_opt = grep_opt . " -s"
821+
else
822+
let grep_opt = grep_opt . " -q"
823+
endif
791824
endif
792825

793826
if a:grep_cmd == 'grep'
@@ -802,6 +835,9 @@ function! s:RunGrep(cmd_name, grep_cmd, action, ...)
802835
elseif a:grep_cmd == 'agrep'
803836
let grep_path = g:Agrep_Path
804837
let grep_expr_option = ''
838+
elseif a:grep_cmd == 'tcgrep'
839+
let grep_path = g:Tcgrep_Path
840+
let grep_expr_option = ''
805841
else
806842
return
807843
endif
@@ -864,6 +900,10 @@ command! -nargs=* -complete=file Agrep
864900
\ call s:RunGrep('Agrep', 'agrep', 'set', <f-args>)
865901
command! -nargs=* -complete=file Ragrep
866902
\ call s:RunGrepRecursive('Ragrep', 'agrep', 'set', <f-args>)
903+
command! -nargs=* -complete=file Tcgrep
904+
\ call s:RunGrep('Tcgrep', 'tcgrep', 'set', <f-args>)
905+
command! -nargs=* -complete=file Rtcgrep
906+
\ call s:RunGrepRecursive('Rtcgrep', 'tcgrep', 'set', <f-args>)
867907

868908
if v:version >= 700
869909
command! -nargs=* -complete=file GrepAdd
@@ -889,6 +929,10 @@ command! -nargs=* -complete=file AgrepAdd
889929
\ call s:RunGrep('AgrepAdd', 'agrep', 'add', <f-args>)
890930
command! -nargs=* -complete=file RagrepAdd
891931
\ call s:RunGrepRecursive('RagrepAdd', 'agrep', 'add', <f-args>)
932+
command! -nargs=* -complete=file TcgrepAdd
933+
\ call s:RunGrep('TcgrepAdd', 'tcgrep', 'add', <f-args>)
934+
command! -nargs=* -complete=file RtcgrepAdd
935+
\ call s:RunGrepRecursive('RtcgrepAdd', 'tcgrep', 'add', <f-args>)
892936
endif
893937

894938
" Add the Tools->Search Files menu

0 commit comments

Comments
 (0)