Skip to content

Commit 1dcfacd

Browse files
committed
Trigger BufWritePre/BufWritePost autocmd events in xolox#notes#save()
It's hard to estimate the consequences of this change, but there's really only one way to find out, hence I'm committing the change. The previous behavior was a bug anyway, it's just that it could have been hiding a lot of other bugs and incompatibilities until now... I'm keeping my fingers crossed ;-) See also issue #88 on GitHub: #88
1 parent a6a654f commit 1dcfacd

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

autoload/xolox/notes.vim

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
" Vim auto-load script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: September 14, 2014
3+
" Last Change: October 20, 2014
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 g:xolox#notes#version = '0.27'
9+
let g:xolox#notes#version = '0.28'
1010
let g:xolox#notes#url_pattern = '\<\(mailto:\|javascript:\|\w\{3,}://\)\(\S*\w\)\+/\?'
1111
let s:scriptdir = expand('<sfile>:p:h')
1212

@@ -404,6 +404,10 @@ function! xolox#notes#save() abort " {{{1
404404
echoerr "Invalid note title"
405405
return
406406
endif
407+
" Trigger the BufWritePre automatic command event because it provides
408+
" a very unobtrusive way for users to extend the vim-notes plug-in.
409+
execute 'doautocmd BufWritePre' fnameescape(newpath)
410+
" Actually save the user's buffer to the file.
407411
let bang = v:cmdbang ? '!' : ''
408412
execute 'saveas' . bang fnameescape(newpath)
409413
" XXX If {oldpath} and {newpath} end up pointing to the same file on disk
@@ -427,6 +431,9 @@ function! xolox#notes#save() abort " {{{1
427431
" Update in-memory list of all notes.
428432
call xolox#notes#cache_del(oldpath)
429433
call xolox#notes#cache_add(newpath, title)
434+
" Trigger the BufWritePost automatic command event because it provides
435+
" a very unobtrusive way for users to extend the vim-notes plug-in.
436+
execute 'doautocmd BufWritePost' fnameescape(newpath)
430437
endif
431438
endfunction
432439

0 commit comments

Comments
 (0)