@@ -45,9 +45,11 @@ function! xolox#notes#tags#create_index() " {{{1
45
45
let filenames = xolox#notes#get_fnames (0 )
46
46
let s: currently_tagged_notes = {}
47
47
for idx in range (len (filenames))
48
- let title = xolox#notes#fname_to_title (filenames[idx])
49
- call xolox#misc#msg#info (" notes.vim %s: Scanning note %i/%i: %s" , g: xolox #notes#version , idx + 1 , len (filenames), title )
50
- call xolox#notes#tags#scan_note (title , join (readfile (filenames[idx]), " \n " ))
48
+ if filereadable (filenames[idx])
49
+ let title = xolox#notes#fname_to_title (filenames[idx])
50
+ call xolox#misc#msg#info (" notes.vim %s: Scanning note %i/%i: %s" , g: xolox #notes#version , idx + 1 , len (filenames), title )
51
+ call xolox#notes#tags#scan_note (title , join (readfile (filenames[idx]), " \n " ))
52
+ endif
51
53
endfor
52
54
if xolox#notes#tags#save_index ()
53
55
let s: previously_tagged_notes = deepcopy (s: currently_tagged_notes )
@@ -58,17 +60,23 @@ function! xolox#notes#tags#create_index() " {{{1
58
60
endfunction
59
61
60
62
function ! xolox#notes#tags#save_index () " {{{1
61
- if s: currently_tagged_notes == s: previously_tagged_notes
63
+ let indexfile = expand (g: notes_tagsindex )
64
+ let existingfile = filereadable (indexfile)
65
+ let nothingchanged = (s: currently_tagged_notes == s: previously_tagged_notes )
66
+ if existingfile && nothingchanged
67
+ call xolox#misc#msg#debug (" notes.vim %s: Index not dirty so not saved." , g: xolox #notes#version )
62
68
return 1 " Nothing to be done
63
69
else
64
70
let lines = []
65
71
for [tagname, filenames] in items (s: currently_tagged_notes )
66
72
call add (lines , join ([tagname] + filenames, " \t " ))
67
73
endfor
68
- let indexfile = expand (g: notes_tagsindex )
69
74
let status = writefile (lines , indexfile) == 0
70
75
if status
76
+ call xolox#misc#msg#debug (" notes.vim %s: Index saved to %s." , g: xolox #notes#version , g: notes_tagsindex )
71
77
let s: last_disk_sync = getftime (indexfile)
78
+ else
79
+ call xolox#misc#msg#debug (" notes.vim %s: Failed to save index to %s." , g: xolox #notes#version , g: notes_tagsindex )
72
80
endif
73
81
return status
74
82
endif
0 commit comments