Skip to content

Commit

Permalink
Add support for "%s" in qcc_query_command
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit e0f3a6f
Author: Mark Stillwell <marklee@fortawesome.org>
Date:   Tue Dec 25 22:25:08 2012 +0000

    update, removed multiline feature temporarily, added support for %s in
    g:qcc_query_command.

commit ab773fa
Author: Mark Stillwell <marklee@fortawesome.org>
Date:   Sun Dec 23 21:09:41 2012 +0000

    fixed regexp to get query command from mutt and added support for multi-line
    address fields.

Ref: #2
  • Loading branch information
caio committed Dec 25, 2012
1 parent e0d84b2 commit 8d34498
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions plugin/querycommandcomplete.vim
Expand Up @@ -51,7 +51,7 @@ endif
" use mutt query command as default
if !exists("g:qcc_query_command")
let s:querycmd = system('mutt -Q query_command 2>/dev/null')
let s:querycmd = substitute(s:querycmd, '^query_command=\"\(.*\) .%s.\"\n', '\1','')
let s:querycmd = substitute(s:querycmd, '^query_command="\(.*\)"\n', '\1','')

if len(s:querycmd)
let g:qcc_query_command = s:querycmd
Expand Down Expand Up @@ -107,12 +107,12 @@ function! s:GenerateCompletions(findstart, base)
return s:FindStartingIndex()
endif

if a:base =~ '^ *$'
return []
endif

let results = []
let cmd = g:qcc_query_command . ' ' . shellescape(a:base)
let cmd = g:qcc_query_command
if cmd !~ '%s'
let cmd .= ' %s'
endif
let cmd = substitute(cmd, '%s', shellescape(a:base), '')
let lines = split(system(cmd), g:qcc_line_separator)

for my_line in lines
Expand All @@ -139,10 +139,7 @@ function! s:GenerateCompletions(findstart, base)
endfunction

function! QueryCommandComplete(findstart, base)
let cur_line = getline(line('.'))

" TODO: Figure out a way to handle multiline
if cur_line =~ g:qcc_pattern
if getline('.') =~ g:qcc_pattern
return s:GenerateCompletions(a:findstart, a:base)
endif
endfunction
Expand Down

0 comments on commit 8d34498

Please sign in to comment.