1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
"
" undoskip.vim: Don't save undo history for temporary or secure files.
"
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
if exists('loaded_undoskip') || &compatible
finish
endif
if !has('persistent_undo') || !exists('*glob2regpat')
finish
endif
let loaded_undoskip = 1
" Set default list of patterns to exclude; mirror documented 'backupskip'
" behavior
if !exists('g:undoskip')
let g:undoskip = []
if has('mac')
call add(g:undoskip, '/private/tmp/*')
elseif has('unix')
call add(g:undoskip, '/tmp/*')
endif
call extend(g:undoskip, map(
\ filter([$TMPDIR, $TMP, $TEMP], 'v:val !=# '''''),
\ 'v:val.''/*'''
\))
endif
" Internal function returns a local value for 'undofile'
function s:CheckUndoSkip(path) abort
" If this isn't a normal buffer, don't save undo data
if &buftype !=# ''
return 0
endif
" Get the path from the buffer name; if that path matches any of the
" patterns, don't save undo data
for glob in g:undoskip
if a:path =~# glob2regpat(glob)
return 0
endif
endfor
" Otherwise, we'll use whatever the global setting is
return &g:undofile
endfunction
" Check the path on every buffer rename, create, or read
augroup undoskip
autocmd!
autocmd BufAdd,BufNewFile,BufRead *
\ let &l:undofile = s:CheckUndoSkip(expand('<amatch>'))
augroup END
|