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.12.1 '
9
+ let g: xolox #notes#version = ' 0.12.2 '
10
10
11
11
function ! xolox#notes#shortcut () " {{{1
12
12
" The "note:" pseudo protocol is just a shortcut for the :Note command.
@@ -34,8 +34,7 @@ function! xolox#notes#edit(bang, title) abort " {{{1
34
34
endif
35
35
" At this point we're dealing with a new note.
36
36
let fname = xolox#notes#title_to_fname (title )
37
- execute ' edit' . a: bang fnameescape (fname)
38
- setlocal filetype = notes
37
+ noautocmd execute ' edit' . a: bang fnameescape (fname)
39
38
if line (' $' ) == 1 && getline (1 ) == ' '
40
39
let fname = xolox#misc#path#merge (g: notes_shadowdir , ' New note' )
41
40
execute ' silent read' fnameescape (fname)
@@ -48,25 +47,31 @@ function! xolox#notes#edit(bang, title) abort " {{{1
48
47
if title != ' New note'
49
48
call setline (1 , title )
50
49
endif
50
+ setlocal filetype = notes
51
51
doautocmd BufReadPost
52
52
call xolox#misc#timer#stop (' notes.vim %s: Started new note in %s.' , g: xolox #notes#version , starttime)
53
53
endfunction
54
54
55
55
function ! xolox#notes#check_sync_title () " {{{1
56
56
if g: notes_title_sync != ' no' && xolox#notes#buffer_is_note ()
57
57
" Check if the note's title and filename are out of sync.
58
+ let title = getline (1 )
58
59
let name_on_disk = xolox#misc#path#absolute (expand (' %:p' ))
59
- let name_from_title = xolox#notes#title_to_fname (getline ( 1 ) )
60
+ let name_from_title = xolox#notes#title_to_fname (title )
60
61
if ! xolox#misc#path#equals (name_on_disk, name_from_title)
62
+ call xolox#misc#msg#debug (" notes.vim %s: Filename (%s) doesn't match note title (%s)" , g: xolox #notes#version , name_on_disk, name_from_title)
61
63
let action = g: notes_title_sync
62
64
if action == ' prompt'
63
65
" Prompt the user what to do (if anything). First we perform a redraw
64
66
" to make sure the note's content is visible (without this the Vim
65
67
" window would be blank in my tests).
66
68
redraw
67
- let message = " The note's title and filename do not correspond. What do you want to do?"
68
- let options = " Change &title\n Rename &file\n Do ¬hing"
69
- let choice = confirm (message, options , 3 , ' Question' )
69
+ let message = " The note's title and filename do not correspond. What do you want to do?\n\n "
70
+ let message .= " Current filename: " . name_on_disk . " \n "
71
+ let message .= " Corresponding title: " . xolox#notes#fname_to_title (name_on_disk) . " \n\n "
72
+ let message .= " Current title: " . title . " \n "
73
+ let message .= " Corresponding filename: " . xolox#notes#title_to_fname (title )
74
+ let choice = confirm (message, " Change &title\n Rename &file\n Do ¬hing" , 3 , ' Question' )
70
75
if choice == 1
71
76
let action = ' change_title'
72
77
elseif choice == 2
0 commit comments