6
6
" Note: This file is encoded in UTF-8 including a byte order mark so
7
7
" that Vim loads the script using the right encoding transparently.
8
8
9
- let g: xolox #notes#version = ' 0.17.4 '
9
+ let g: xolox #notes#version = ' 0.17.5 '
10
10
let s: scriptdir = expand (' <sfile>:p:h' )
11
11
12
12
call xolox#misc#compat#check (' notes' , 1 )
@@ -398,16 +398,13 @@ function! xolox#notes#search(bang, input) " {{{1
398
398
endif
399
399
if input = ~ ' ^/.\+/$'
400
400
call s: internal_search (a: bang , input , ' ' , ' ' )
401
- if &buftype == ' quickfix'
402
- let w: quickfix_title = ' Notes matching the pattern ' . input
403
- endif
401
+ call s: set_quickfix_title ([], input )
404
402
else
405
403
let keywords = split (input )
406
404
let all_keywords = s: match_all_keywords (keywords)
407
405
let any_keyword = s: match_any_keyword (keywords)
408
406
call s: internal_search (a: bang , all_keywords, input , any_keyword)
409
407
if &buftype == ' quickfix'
410
- call map (keywords, ' "`" . v:val . "'' "' )
411
408
" Enable line wrapping in the quick-fix window.
412
409
setlocal wrap
413
410
" Resize the quick-fix window to 1/3 of the screen height.
@@ -418,8 +415,7 @@ function! xolox#notes#search(bang, input) " {{{1
418
415
let preferred_height = winline ()
419
416
execute ' resize' min ([max_height, preferred_height])
420
417
normal gg
421
- let w: quickfix_title = printf (' Notes containing the word%s %s' , len (keywords) == 1 ? ' ' : ' s' ,
422
- \ len (keywords) > 1 ? (join (keywords[0 :-2 ], ' , ' ) . ' and ' . keywords[-1 ]) : keywords[0 ])
418
+ call s: set_quickfix_title (keywords, ' ' )
423
419
endif
424
420
endif
425
421
call xolox#misc#timer#stop (" notes.vim %s: Searched notes in %s." , g: xolox #notes#version , starttime)
@@ -450,6 +446,24 @@ function! s:match_any_keyword(keywords) " {{{2
450
446
return ' /' . escape (join (results, ' \|' ), ' /' ) . ' /'
451
447
endfunction
452
448
449
+ function ! s: set_quickfix_title (keywords, pattern) " {{{2
450
+ " Set the title of the quick-fix window.
451
+ if &buftype == ' quickfix'
452
+ let num_notes = len (xolox#misc#list#unique (map (getqflist (), ' v:val["bufnr"]' )))
453
+ if len (a: keywords ) > 0
454
+ let keywords = map (copy (a: keywords ), ' "`" . v:val . "'' "' )
455
+ let w: quickfix_title = printf (' Found %i note%s containing the word%s %s' ,
456
+ \ num_notes, num_notes == 1 ? ' ' : ' s' ,
457
+ \ len (keywords) == 1 ? ' ' : ' s' ,
458
+ \ len (keywords) > 1 ? (join (keywords[0 :-2 ], ' , ' ) . ' and ' . keywords[-1 ]) : keywords[0 ])
459
+ else
460
+ let w: quickfix_title = printf (' Found %i note%s containing the pattern %s' ,
461
+ \ num_notes, num_notes == 1 ? ' ' : ' s' ,
462
+ \ a: pattern )
463
+ endif
464
+ endif
465
+ endfunction
466
+
453
467
function ! xolox#notes#related (bang ) " {{{1
454
468
" Find all notes related to the current note or file.
455
469
let starttime = xolox#misc#timer#start ()
0 commit comments