aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-25 21:55:51 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-25 21:56:24 +1200
commit66fa75c8ca81e012079a69e9e4f0bd2ca69f0a09 (patch)
treed585bf163aa834526d2eeecf36e4dd6cc1ba0123
parent1f2ab8d4fecbc7b1061dd4108d33962621017d25 (diff)
downloadvim-redact-pass-66fa75c8ca81e012079a69e9e4f0bd2ca69f0a09.tar.gz
vim-redact-pass-66fa75c8ca81e012079a69e9e4f0bd2ca69f0a09.zip
Move code into autoloaded function
-rw-r--r--autoload/redact_pass.vim23
-rw-r--r--plugin/redact_pass.vim26
2 files changed, 24 insertions, 25 deletions
diff --git a/autoload/redact_pass.vim b/autoload/redact_pass.vim
new file mode 100644
index 0000000..da1c101
--- /dev/null
+++ b/autoload/redact_pass.vim
@@ -0,0 +1,23 @@
+" Check whether we should set redacting options or not
+function! redact_pass#CheckArgsRedact() abort
+
+ " Ensure there's one argument and it's the matched file
+ if argc() != 1 || fnamemodify(argv(0), ':p') !=# expand('<afile>:p')
+ return
+ endif
+
+ " Disable all the leaky options globally
+ set nobackup
+ set nowritebackup
+ set noswapfile
+ set viminfo=
+ if has('persistent_undo')
+ set noundofile
+ endif
+
+ " Tell the user what we're doing so they know this worked, via a message and
+ " a global variable they can check
+ echomsg 'Editing password file--disabled leaky options!'
+ let g:redact_pass_redacted = 1
+
+endfunction
diff --git a/plugin/redact_pass.vim b/plugin/redact_pass.vim
index 42064e4..3e30d88 100644
--- a/plugin/redact_pass.vim
+++ b/plugin/redact_pass.vim
@@ -16,30 +16,6 @@ if v:version < 700
endif
let loaded_redact_pass = 1
-" Check whether we should set redacting options or not
-function! s:CheckArgsRedact()
-
- " Ensure there's one argument and it's the matched file
- if argc() != 1 || fnamemodify(argv(0), ':p') !=# expand('<afile>:p')
- return
- endif
-
- " Disable all the leaky options globally
- set nobackup
- set nowritebackup
- set noswapfile
- set viminfo=
- if has('persistent_undo')
- set noundofile
- endif
-
- " Tell the user what we're doing so they know this worked, via a message and
- " a global variable they can check
- echomsg 'Editing password file--disabled leaky options!'
- let g:redact_pass_redacted = 1
-
-endfunction
-
" Auto function loads only when Vim starts up
augroup redact_pass
autocmd!
@@ -47,5 +23,5 @@ augroup redact_pass
\ /dev/shm/pass.?*/?*.txt
\,$TMPDIR/pass.?*/?*.txt
\,/tmp/pass.?*/?*.txt
- \ call s:CheckArgsRedact()
+ \ call redact_pass#CheckArgsRedact()
augroup END