Skip to content

Commit 23861b0

Browse files
committed
Define version as variable, include version in messages
1 parent 6468ae9 commit 23861b0

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

autoload/xolox/notes.vim

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
" Vim auto-load script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: June 14, 2011
3+
" Last Change: June 24, 2011
44
" URL: http://peterodding.com/code/vim/notes/
55

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 s:script = expand('<sfile>:p:~')
10-
119
function! xolox#notes#shortcut() " {{{1
1210
" The "note:" pseudo protocol is just a shortcut for the :Note command.
1311
let name = matchstr(expand('<afile>'), 'note:\zs.*')
@@ -26,7 +24,7 @@ function! xolox#notes#edit(bang, title) abort " {{{1
2624
call s:transcode_utf8_latin1()
2725
endif
2826
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)
3028
return
3129
endif
3230
else
@@ -48,7 +46,7 @@ function! xolox#notes#edit(bang, title) abort " {{{1
4846
call setline(1, title)
4947
endif
5048
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)
5250
endfunction
5351

5452
function! xolox#notes#from_selection(bang) " {{{1
@@ -211,7 +209,7 @@ function! xolox#notes#delete(bang) " {{{1
211209
" Delete the current note, close the associated buffer & window.
212210
let filename = expand('%:p')
213211
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)
215213
return
216214
endif
217215
call xolox#notes#cache_del(filename)
@@ -224,7 +222,7 @@ function! xolox#notes#search(bang, input) " {{{1
224222
if input == ''
225223
let input = s:tag_under_cursor()
226224
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)
228226
return
229227
endif
230228
endif
@@ -281,7 +279,7 @@ function! xolox#notes#related(bang) " {{{1
281279
" Find all notes related to the current note or file.
282280
let bufname = bufname('%')
283281
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)
285283
else
286284
let filename = xolox#misc#path#absolute(bufname)
287285
if &filetype == 'notes' && xolox#misc#path#equals(g:notes_directory, expand('%:h'))
@@ -304,7 +302,7 @@ function! xolox#notes#related(bang) " {{{1
304302
let w:quickfix_title = 'Notes related to ' . friendly_path
305303
endif
306304
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)
308306
endtry
309307
endif
310308
endfunction
@@ -378,7 +376,7 @@ function! xolox#notes#recent(bang, title_filter) " {{{1
378376
endfor
379377
call setline(line('$') + 1, lines)
380378
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)
382380
endfunction
383381

384382
" Miscellaneous functions. {{{1
@@ -399,7 +397,7 @@ function! s:internal_search(bang, pattern, keywords, phase2) " {{{2
399397
let phase2_needed = 1
400398
if a:keywords != '' && s:run_scanner(a:keywords, notes)
401399
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)
403401
return
404402
endif
405403
let pattern = a:phase2 != '' ? a:phase2 : pattern
@@ -430,7 +428,7 @@ function! s:internal_search(bang, pattern, keywords, phase2) " {{{2
430428
setlocal ignorecase
431429
execute 'match IncSearch' pattern
432430
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)
434432
endfunction
435433

436434
function! s:vimgrep_wrapper(bang, pattern, files) " {{{2
@@ -465,7 +463,7 @@ function! s:run_scanner(keywords, matches) " {{{2
465463
let python = 'python2'
466464
endif
467465
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)
469467
else
470468
let arguments = [scanner, g:notes_indexfile, g:notes_directory, g:notes_shadowdir, a:keywords]
471469
call map(arguments, 'shellescape(v:val)')
@@ -474,7 +472,7 @@ function! s:run_scanner(keywords, matches) " {{{2
474472
call extend(a:matches, split(output, '\n'))
475473
return 1
476474
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)
478476
endif
479477
endif
480478
endfunction
@@ -501,7 +499,7 @@ function! xolox#notes#get_fnames() " {{{3
501499
call extend(s:cached_fnames, split(listing, '\n'))
502500
endfor
503501
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)
505503
endif
506504
return copy(s:cached_fnames)
507505
endfunction
@@ -514,7 +512,7 @@ function! xolox#notes#get_titles() " {{{3
514512
call add(s:cached_titles, xolox#notes#fname_to_title(filename))
515513
endfor
516514
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)
518516
endif
519517
return copy(s:cached_titles)
520518
endfunction
@@ -532,7 +530,7 @@ function! xolox#notes#get_fnames_and_titles() " {{{3
532530
let index += 1
533531
endwhile
534532
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)
536534
endif
537535
return s:cached_pairs
538536
endfunction
@@ -645,7 +643,7 @@ function! xolox#notes#highlight_names(force) " {{{3
645643
syntax clear notesName
646644
execute 'syntax match notesName /\c\%>2l\<\%(' . escape(join(titles, '\|'), '/') . '\)\>/'
647645
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)
649647
endif
650648
endfunction
651649

@@ -674,7 +672,7 @@ function! xolox#notes#highlight_sources(sg, eg) " {{{3
674672
let command = 'syntax region %s matchgroup=%s start="{{{%s" matchgroup=%s end="}}}" keepend contains=%s%s'
675673
execute printf(command, group, a:sg, ft, a:eg, include, has('conceal') ? ' concealends' : '')
676674
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)
678676
endfunction
679677

680678
function! s:syntax_include(filetype)

plugin/notes.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
" Vim plug-in
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: June 17, 2011
3+
" Last Change: June 24, 2011
44
" URL: http://peterodding.com/code/vim/notes/
5-
" License: MIT
6-
" Version: 0.9.2
75

86
" Support for automatic update using the GLVS plug-in.
97
" GetLatestVimScripts: 3375 1 :AutoInstall: notes.zip
108

11-
" Don't source the plug-in when its already been loaded or &compatible is set.
9+
" Don't source the plug-in when it's already been loaded or &compatible is set.
1210
if &cp || exists('g:loaded_notes')
1311
finish
1412
endif
1513

14+
let g:notes_version = '0.9.3'
15+
1616
" Make sure the default paths below are compatible with Pathogen.
1717
let s:plugindir = expand('<sfile>:p:h') . '/../misc/notes'
1818

0 commit comments

Comments
 (0)