1
1
" Vim auto-load script
2
2
" Author: Peter Odding <peter@peterodding.com>
3
- " Last Change: June 14 , 2011
3
+ " Last Change: June 24 , 2011
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 s: script = expand (' <sfile>:p:~' )
10
-
11
9
function ! xolox#notes#shortcut () " {{{1
12
10
" The "note:" pseudo protocol is just a shortcut for the :Note command.
13
11
let name = matchstr (expand (' <afile>' ), ' note:\zs.*' )
@@ -26,7 +24,7 @@ function! xolox#notes#edit(bang, title) abort " {{{1
26
24
call s: transcode_utf8_latin1 ()
27
25
endif
28
26
setlocal filetype = notes
29
- call xolox#misc#timer#stop (' %s: Opened note in %s.' , s: script , starttime)
27
+ call xolox#misc#timer#stop (' notes.vim %s: Opened note in %s.' , g: notes_version , starttime)
30
28
return
31
29
endif
32
30
else
@@ -48,7 +46,7 @@ function! xolox#notes#edit(bang, title) abort " {{{1
48
46
call setline (1 , title )
49
47
endif
50
48
doautocmd BufReadPost
51
- call xolox#misc#timer#stop (' %s: Started new note in %s.' , s: script , starttime)
49
+ call xolox#misc#timer#stop (' notes.vim %s: Started new note in %s.' , g: notes_version , starttime)
52
50
endfunction
53
51
54
52
function ! xolox#notes#from_selection (bang ) " {{{1
@@ -211,7 +209,7 @@ function! xolox#notes#delete(bang) " {{{1
211
209
" Delete the current note, close the associated buffer & window.
212
210
let filename = expand (' %:p' )
213
211
if filereadable (filename) && delete (filename)
214
- call xolox#misc#msg#warn (" %s: Failed to delete %s!" , s: script , filename)
212
+ call xolox#misc#msg#warn (" notes.vim %s: Failed to delete %s!" , g: notes_version , filename)
215
213
return
216
214
endif
217
215
call xolox#notes#cache_del (filename)
@@ -224,7 +222,7 @@ function! xolox#notes#search(bang, input) " {{{1
224
222
if input == ' '
225
223
let input = s: tag_under_cursor ()
226
224
if input == ' '
227
- call xolox#misc#msg#warn (" No string under cursor" )
225
+ call xolox#misc#msg#warn (" notes.vim %s: No string under cursor" , g: notes_version )
228
226
return
229
227
endif
230
228
endif
@@ -281,7 +279,7 @@ function! xolox#notes#related(bang) " {{{1
281
279
" Find all notes related to the current note or file.
282
280
let bufname = bufname (' %' )
283
281
if bufname == ' '
284
- call xolox#misc#msg#warn (" %s: :RelatedNotes only works on named buffers!" , s: script )
282
+ call xolox#misc#msg#warn (" notes.vim %s: :RelatedNotes only works on named buffers!" , g: notes_version )
285
283
else
286
284
let filename = xolox#misc#path#absolute (bufname )
287
285
if &filetype == ' notes' && xolox#misc#path#equals (g: notes_directory , expand (' %:h' ))
@@ -304,7 +302,7 @@ function! xolox#notes#related(bang) " {{{1
304
302
let w: quickfix_title = ' Notes related to ' . friendly_path
305
303
endif
306
304
catch /^Vim\%((\a\+)\)\=:E480/
307
- call xolox#misc#msg#warn (" %s: No related notes found for %s" , s: script , friendly_path)
305
+ call xolox#misc#msg#warn (" notes.vim %s: No related notes found for %s" , g: notes_version , friendly_path)
308
306
endtry
309
307
endif
310
308
endfunction
@@ -378,7 +376,7 @@ function! xolox#notes#recent(bang, title_filter) " {{{1
378
376
endfor
379
377
call setline (line (' $' ) + 1 , lines )
380
378
setlocal readonly nomodifiable nomodified filetype = notes
381
- call xolox#misc#timer#stop (" %s: Created list of notes in %s." , s: script , start )
379
+ call xolox#misc#timer#stop (" notes.vim %s: Created list of notes in %s." , g: notes_version , start )
382
380
endfunction
383
381
384
382
" Miscellaneous functions. {{{1
@@ -399,7 +397,7 @@ function! s:internal_search(bang, pattern, keywords, phase2) " {{{2
399
397
let phase2_needed = 1
400
398
if a: keywords != ' ' && s: run_scanner (a: keywords , notes)
401
399
if notes == []
402
- call xolox#misc#msg#warn (" E480 : No matches" )
400
+ call xolox#misc#msg#warn (" notes.vim %s : No matches" , g: notes_version )
403
401
return
404
402
endif
405
403
let pattern = a: phase2 != ' ' ? a: phase2 : pattern
@@ -430,7 +428,7 @@ function! s:internal_search(bang, pattern, keywords, phase2) " {{{2
430
428
setlocal ignorecase
431
429
execute ' match IncSearch' pattern
432
430
endif
433
- call xolox#misc#timer#stop (' %s: Searched notes in %s.' , s: script , starttime)
431
+ call xolox#misc#timer#stop (' notes.vim %s: Searched notes in %s.' , g: notes_version , starttime)
434
432
endfunction
435
433
436
434
function ! s: vimgrep_wrapper (bang , pattern, files ) " {{{2
@@ -465,7 +463,7 @@ function! s:run_scanner(keywords, matches) " {{{2
465
463
let python = ' python2'
466
464
endif
467
465
if ! (executable (python ) && filereadable (scanner))
468
- call xolox#misc#msg#debug (" %s: The %s script isn't executable." , s: script , scanner)
466
+ call xolox#misc#msg#debug (" notes.vim %s: The %s script isn't executable." , g: notes_version , scanner)
469
467
else
470
468
let arguments = [scanner, g: notes_indexfile , g: notes_directory , g: notes_shadowdir , a: keywords ]
471
469
call map (arguments, ' shellescape(v:val)' )
@@ -474,7 +472,7 @@ function! s:run_scanner(keywords, matches) " {{{2
474
472
call extend (a: matches , split (output, ' \n' ))
475
473
return 1
476
474
else
477
- call xolox#misc#msg#warn (" %s: scanner.py failed with output: %s" , s: script , output)
475
+ call xolox#misc#msg#warn (" notes.vim %s: scanner.py failed with output: %s" , g: notes_version , output)
478
476
endif
479
477
endif
480
478
endfunction
@@ -501,7 +499,7 @@ function! xolox#notes#get_fnames() " {{{3
501
499
call extend (s: cached_fnames , split (listing, ' \n' ))
502
500
endfor
503
501
let s: have_cached_names = 1
504
- call xolox#misc#timer#stop (' %s: Cached note filenames in %s.' , s: script , starttime)
502
+ call xolox#misc#timer#stop (' notes.vim %s: Cached note filenames in %s.' , g: notes_version , starttime)
505
503
endif
506
504
return copy (s: cached_fnames )
507
505
endfunction
@@ -514,7 +512,7 @@ function! xolox#notes#get_titles() " {{{3
514
512
call add (s: cached_titles , xolox#notes#fname_to_title (filename))
515
513
endfor
516
514
let s: have_cached_titles = 1
517
- call xolox#misc#timer#stop (' %s: Cached note titles in %s.' , s: script , starttime)
515
+ call xolox#misc#timer#stop (' notes.vim %s: Cached note titles in %s.' , g: notes_version , starttime)
518
516
endif
519
517
return copy (s: cached_titles )
520
518
endfunction
@@ -532,7 +530,7 @@ function! xolox#notes#get_fnames_and_titles() " {{{3
532
530
let index += 1
533
531
endwhile
534
532
let s: have_cached_items = 1
535
- call xolox#misc#timer#stop (' %s: Cached note filenames and titles in %s.' , s: script , starttime)
533
+ call xolox#misc#timer#stop (' notes.vim %s: Cached note filenames and titles in %s.' , g: notes_version , starttime)
536
534
endif
537
535
return s: cached_pairs
538
536
endfunction
@@ -645,7 +643,7 @@ function! xolox#notes#highlight_names(force) " {{{3
645
643
syntax clear notesName
646
644
execute ' syntax match notesName /\c\%>2l\<\%(' . escape (join (titles, ' \|' ), ' /' ) . ' \)\>/'
647
645
let b: notes_names_last_highlighted = localtime ()
648
- call xolox#misc#timer#stop (" %s: Highlighted note names in %s." , s: script , starttime)
646
+ call xolox#misc#timer#stop (" notes.vim %s: Highlighted note names in %s." , g: notes_version , starttime)
649
647
endif
650
648
endfunction
651
649
@@ -674,7 +672,7 @@ function! xolox#notes#highlight_sources(sg, eg) " {{{3
674
672
let command = ' syntax region %s matchgroup=%s start="{{{%s" matchgroup=%s end="}}}" keepend contains=%s%s'
675
673
execute printf (command , group, a: sg , ft , a: eg , include , has (' conceal' ) ? ' concealends' : ' ' )
676
674
endfor
677
- call xolox#misc#timer#stop (" %s: Highlighted embedded sources in %s." , s: script , starttime)
675
+ call xolox#misc#timer#stop (" notes.vim %s: Highlighted embedded sources in %s." , g: notes_version , starttime)
678
676
endfunction
679
677
680
678
function ! s: syntax_include (filetype )
0 commit comments