Skip to content

Commit 2924184

Browse files
author
Bruno Sutic
committed
Small refactor
1 parent a3ebb3b commit 2924184

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

autoload/man/grep.vim

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,18 @@ endfunction
122122

123123
" TODO: can this whole command be simplified?
124124
function! man#grep#command(path_glob, insensitive_flag, pattern)
125-
let do_glob = 'ls '.a:path_glob.' 2>/dev/null |'
126-
125+
let command = 'ls '.a:path_glob.' 2>/dev/null |'
127126
" xargs is used to feed manpages one-by-one
128-
let xargs = 'xargs -I{} -n1 sh -c "manpage={};'
129-
127+
let command .= 'xargs -I{} -n1 sh -c "manpage={};'
130128
" inner variables execute within a shell started by xargs
131-
let inner_output_manfile = '/usr/bin/man \$manpage 2>/dev/null|col -b|'
132-
129+
let command .= '/usr/bin/man \$manpage 2>/dev/null|col -b|'
133130
" if the first manpage line is blank, remove it (stupid semicolons are required)
134-
let inner_trim_whitespace = "sed '1 {;/^\s*$/d;}'|"
135-
let inner_grep = 'grep '.a:insensitive_flag.' -nE '.a:pattern.'|'
136-
131+
let command .= "sed '1 {;/^\s*$/d;}'|"
132+
let command .= 'grep '.a:insensitive_flag.' -nE '.a:pattern.'|'
137133
" prepending filename to each line of grep output, followed by a !
138-
let inner_append_filename = 'sed "s,^,\$manpage!,"'
139-
let end_quot = '"'
140-
141-
return do_glob.xargs.inner_output_manfile.inner_trim_whitespace.inner_grep.inner_append_filename.end_quot
134+
let command .= 'sed "s,^,\$manpage!,"'
135+
let command .= '"'
136+
return command
142137
endfunction
143138

144139
" }}}

0 commit comments

Comments
 (0)