Skip to content
Browse files

Add support for "%s" in qcc_query_command

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...
1 parent e0d84b2 commit 8d344989a52e157d7674294b5e7b32e5b88a876e @caio committed Dec 26, 2012
Showing with 7 additions and 10 deletions.
  1. +7 −10 plugin/querycommandcomplete.vim
View
17 plugin/querycommandcomplete.vim
@@ -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
@@ -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
@@ -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

0 comments on commit 8d34498

Please sign in to comment.
Something went wrong with that request. Please try again.