|
1 | 1 | " Vim auto-load script
|
2 | 2 | " Author: Peter Odding <[email protected]>
|
3 |
| -" Last Change: November 1, 2015 |
| 3 | +" Last Change: November 4, 2015 |
4 | 4 | " URL: http://peterodding.com/code/vim/notes/
|
5 | 5 |
|
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.33.3' |
| 9 | +let g:xolox#notes#version = '0.33.4' |
10 | 10 | let g:xolox#notes#url_pattern = '\<\(mailto:\|javascript:\|\w\{3,}://\)\(\S*\w\)\+/\?'
|
11 | 11 | let s:scriptdir = expand('<sfile>:p:h')
|
12 | 12 |
|
@@ -471,46 +471,40 @@ endfunction
|
471 | 471 |
|
472 | 472 | function! xolox#notes#search(bang, input) " {{{1
|
473 | 473 | " Search all notes for the pattern or keywords {input} (current word if none given).
|
474 |
| - try |
475 |
| - let starttime = xolox#misc#timer#start() |
476 |
| - let input = a:input |
| 474 | + let starttime = xolox#misc#timer#start() |
| 475 | + let input = a:input |
| 476 | + if input == '' |
| 477 | + let input = s:tag_under_cursor() |
477 | 478 | if input == ''
|
478 |
| - let input = s:tag_under_cursor() |
479 |
| - if input == '' |
480 |
| - call xolox#misc#msg#warn("notes.vim %s: No string under cursor", g:xolox#notes#version) |
481 |
| - return |
482 |
| - endif |
| 479 | + call xolox#misc#msg#warn("notes.vim %s: No string under cursor", g:xolox#notes#version) |
| 480 | + return |
483 | 481 | endif
|
484 |
| - if input =~ '^/.\+/$' |
485 |
| - call xolox#misc#msg#debug("notes.vim %s: Performing pattern search (%s) ..", g:xolox#notes#version, input) |
486 |
| - call s:internal_search(a:bang, input, '', '') |
487 |
| - call s:set_quickfix_title([], input) |
488 |
| - else |
489 |
| - let keywords = split(input) |
490 |
| - let all_keywords = s:match_all_keywords(keywords) |
491 |
| - let any_keyword = s:match_any_keyword(keywords) |
492 |
| - call xolox#misc#msg#debug("notes.vim %s: Performing keyword search (%s) ..", g:xolox#notes#version, input) |
493 |
| - call s:internal_search(a:bang, all_keywords, input, any_keyword) |
494 |
| - if &buftype == 'quickfix' |
495 |
| - " Enable line wrapping in the quick-fix window. |
496 |
| - setlocal wrap |
497 |
| - " Resize the quick-fix window to 1/3 of the screen height. |
498 |
| - let max_height = &lines / 3 |
499 |
| - execute 'resize' max_height |
500 |
| - " Make it smaller if the content doesn't fill the window. |
501 |
| - normal G$ |
502 |
| - let preferred_height = winline() |
503 |
| - execute 'resize' min([max_height, preferred_height]) |
504 |
| - normal gg |
505 |
| - call s:set_quickfix_title(keywords, '') |
506 |
| - endif |
| 482 | + endif |
| 483 | + if input =~ '^/.\+/$' |
| 484 | + call xolox#misc#msg#debug("notes.vim %s: Performing pattern search (%s) ..", g:xolox#notes#version, input) |
| 485 | + call s:internal_search(a:bang, input, '', '') |
| 486 | + call s:set_quickfix_title([], input) |
| 487 | + else |
| 488 | + let keywords = split(input) |
| 489 | + let all_keywords = s:match_all_keywords(keywords) |
| 490 | + let any_keyword = s:match_any_keyword(keywords) |
| 491 | + call xolox#misc#msg#debug("notes.vim %s: Performing keyword search (%s) ..", g:xolox#notes#version, input) |
| 492 | + call s:internal_search(a:bang, all_keywords, input, any_keyword) |
| 493 | + if &buftype == 'quickfix' |
| 494 | + " Enable line wrapping in the quick-fix window. |
| 495 | + setlocal wrap |
| 496 | + " Resize the quick-fix window to 1/3 of the screen height. |
| 497 | + let max_height = &lines / 3 |
| 498 | + execute 'resize' max_height |
| 499 | + " Make it smaller if the content doesn't fill the window. |
| 500 | + normal G$ |
| 501 | + let preferred_height = winline() |
| 502 | + execute 'resize' min([max_height, preferred_height]) |
| 503 | + normal gg |
| 504 | + call s:set_quickfix_title(keywords, '') |
507 | 505 | endif
|
508 |
| - call xolox#misc#timer#stop("notes.vim %s: Searched notes in %s.", g:xolox#notes#version, starttime) |
509 |
| - catch /^Vim\%((\a\+)\)\=:E480/ |
510 |
| - call xolox#misc#msg#warn("notes.vim %s: No matches", g:xolox#notes#version) |
511 |
| - catch |
512 |
| - call xolox#misc#msg#warn("notes.vim %s: Encountered error during search: %s (%s)", g:xolox#notes#version, v:exception, v:throwpoint) |
513 |
| - endtry |
| 506 | + endif |
| 507 | + call xolox#misc#timer#stop("notes.vim %s: Searched notes in %s.", g:xolox#notes#version, starttime) |
514 | 508 | endfunction
|
515 | 509 |
|
516 | 510 | function! s:tag_under_cursor() " {{{2
|
|
0 commit comments