|
1 | 1 | " Vim auto-load script
|
2 | 2 | " Author: Peter Odding <peter@peterodding.com>
|
3 |
| -" Last Change: November1, 2015 |
| 3 | +" Last Change: November4, 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 |
| -letg:xolox#notes#version='0.33.3' |
| 9 | +letg:xolox#notes#version='0.33.4' |
10 | 10 | letg:xolox#notes#url_pattern='\<\(mailto:\|#"diff-9dabcf74fee8f5a7b9ab5c351b817a2ff52dfa9fe6eaf24dddc2a0d2b53c0ba7-11-11-0" data-selected="false" role="gridcell" tabindex="-1" valign="top">11
| 11 | lets: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 |
| -letinput=a:input |
| 474 | +let starttime=xolox#misc#timer#start() |
| 475 | +letinput=a:input |
| 476 | +ifinput=='' |
| 477 | +letinput=s:tag_under_cursor() |
477 | 478 | ifinput==''
|
478 |
| -letinput=s:tag_under_cursor() |
479 |
| -ifinput=='' |
480 |
| -callxolox#misc#msg#warn("notes.vim %s: No string under cursor",g:xolox#notes#version) |
481 |
| -return |
482 |
| -endif |
| 479 | +callxolox#misc#msg#warn("notes.vim %s: No string under cursor",g:xolox#notes#version) |
| 480 | +return |
483 | 481 | endif
|
484 |
| -ifinput=~'^/.\+/$' |
485 |
| -callxolox#misc#msg#debug("notes.vim %s: Performing pattern search (%s) ..",g:xolox#notes#version,input) |
486 |
| -calls:internal_search(a:bang,input,'','') |
487 |
| -calls:set_quickfix_title([],input) |
488 |
| -else |
489 |
| -let keywords=split(input) |
490 |
| -letall_keywords=s:match_all_keywords(keywords) |
491 |
| -letany_keyword=s:match_any_keyword(keywords) |
492 |
| -callxolox#misc#msg#debug("notes.vim %s: Performing keyword search (%s) ..",g:xolox#notes#version,input) |
493 |
| -calls:internal_search(a:bang, all_keywords,input, any_keyword) |
494 |
| -if &buftype=='quickfix' |
495 |
| -" Enable line wrapping in the quick-fix window. |
496 |
| -setlocalwrap |
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 |
| -calls:set_quickfix_title(keywords,'') |
506 |
| -endif |
| 482 | +endif |
| 483 | +ifinput=~'^/.\+/$' |
| 484 | +callxolox#misc#msg#debug("notes.vim %s: Performing pattern search (%s) ..",g:xolox#notes#version,input) |
| 485 | +calls:internal_search(a:bang,input,'','') |
| 486 | +calls:set_quickfix_title([],input) |
| 487 | +else |
| 488 | +letkeywords=split(input) |
| 489 | +letall_keywords=s:match_all_keywords(keywords) |
| 490 | +let any_keyword=s:match_any_keyword(keywords) |
| 491 | +callxolox#misc#msg#debug("notes.vim %s: Performing keyword search (%s) ..",g:xolox#notes#version,input) |
| 492 | +calls:internal_search(a:bang, all_keywords,input, any_keyword) |
| 493 | +if &buftype=='quickfix' |
| 494 | +" Enable line wrapping in the quick-fix window. |
| 495 | +setlocalwrap |
| 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 | +calls:set_quickfix_title(keywords,'') |
507 | 505 | endif
|
508 |
| -callxolox#misc#timer#stop("notes.vim %s: Searched notes in %s.",g:xolox#notes#version, starttime) |
509 |
| -catch/^Vim\%((\a\+)\)\=:E480/ |
510 |
| -callxolox#misc#msg#warn("notes.vim %s: No matches",g:xolox#notes#version) |
511 |
| -catch |
512 |
| -callxolox#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 | +callxolox#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
|
|