Skip to content

Commit 6107bdf

Browse files
committed
Improve verbose output & timing for keyword searches
1 parent 8f82c18 commit 6107bdf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

autoload/xolox/notes.vim

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
" Note: This file is encoded in UTF-8 including a byte order mark so
77
" that Vim loads the script using the right encoding transparently.
88

9-
let g:xolox#notes#version = '0.17.6'
9+
let g:xolox#notes#version = '0.17.7'
1010
let s:scriptdir = expand('<sfile>:p:h')
1111

1212
call xolox#misc#compat#check('notes', 1)
@@ -673,13 +673,15 @@ endfunction
673673

674674
function! s:vimgrep_wrapper(bang, pattern, files) " {{{2
675675
" Search for {pattern} in {files} using :vimgrep.
676+
let starttime = xolox#misc#timer#start()
676677
let args = map(copy(a:files), 'fnameescape(v:val)')
677678
call insert(args, a:pattern . 'j')
678679
let s:swaphack_enabled = 1
679680
try
680681
let ei_save = &eventignore
681682
set eventignore=syntax,bufread
682683
execute 'vimgrep' . a:bang join(args)
684+
call xolox#misc#timer#stop("notes.vim %s: Populated quick-fix window in %s.", g:xolox#notes#version, starttime)
683685
finally
684686
let &eventignore = ei_save
685687
unlet s:swaphack_enabled
@@ -697,8 +699,10 @@ endfunction
697699

698700
function! s:run_scanner(keywords, matches) " {{{2
699701
" Try to run scanner.py script to find notes matching {keywords}.
702+
call xolox#misc#msg#info("notes.vim %s: Searching notes using keyword index ..", g:xolox#notes#version)
700703
let lines = s:python_command(a:keywords)
701704
if type(lines) == type([])
705+
call xolox#misc#msg#debug("notes.vim %s: Search script reported %i matching note%s.", g:xolox#notes#version, len(lines), len(lines) == 1 ? '' : 's')
702706
call extend(a:matches, lines)
703707
return 1
704708
endif
@@ -718,7 +722,7 @@ function! s:python_command(...) " {{{2
718722
let script = xolox#misc#path#absolute(g:notes_indexscript)
719723
let python = executable('python2') ? 'python2' : 'python'
720724
if !(executable(python) && filereadable(script))
721-
call xolox#misc#msg#debug("notes.vim %s: The %s script isn't executable.", g:xolox#notes#version, script)
725+
call xolox#misc#msg#debug("notes.vim %s: We can't execute the %s script!", g:xolox#notes#version, script)
722726
else
723727
let options = ['--database', g:notes_indexfile, '--notes', g:notes_directory]
724728
if &ignorecase
@@ -735,9 +739,11 @@ function! s:python_command(...) " {{{2
735739
call xolox#misc#msg#warn("notes.vim %s: Search script failed with output: %s", g:xolox#notes#version, output)
736740
else
737741
let lines = split(output, "\n")
742+
call xolox#misc#msg#debug("notes.vim %s: Search script output: %s", g:xolox#notes#version, string(lines))
738743
if !empty(lines) && lines[0] == 'Python works fine!'
739744
return lines[1:]
740745
endif
746+
call xolox#misc#msg#debug("notes.vim %s: Search script returned invalid output :-(", g:xolox#notes#version)
741747
endif
742748
endif
743749
endfunction

0 commit comments

Comments
 (0)