mirror of
https://github.com/Ascyii/vim-gnupg.git
synced 2026-01-01 06:14:24 -05:00
Allow definition of actions specific to GnuPG-managed buffers
If there are specific actions that should take place when editing a
GnuPG-managed buffer, an autocmd for the User event and GnuPG pattern
can be defined. For example, the following will set 'textwidth' to 72
for all GnuPG-encrypted buffers:
autocmd User GnuPG setl textwidth=72
This will be triggered before any BufRead or BufNewFile autocmds, and
therefore will not take precedence over settings specific to any
filetype that may get set.
Closes jamessan/vim-gnupg#10
Signed-off-by: James McCoy <vega.james@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
" Name: gnupg.vim
|
" Name: gnupg.vim
|
||||||
" Last Change: 2013 Jan 24
|
" Last Change: 2013 Apr 23
|
||||||
" Maintainer: James McCoy <vega.james@gmail.com>
|
" Maintainer: James McCoy <vega.james@gmail.com>
|
||||||
" Original Author: Markus Braun <markus.braun@krawel.de>
|
" Original Author: Markus Braun <markus.braun@krawel.de>
|
||||||
" Summary: Vim plugin for transparent editing of gpg encrypted files.
|
" Summary: Vim plugin for transparent editing of gpg encrypted files.
|
||||||
@@ -42,6 +42,17 @@
|
|||||||
" Most distributions provide software to ease handling of gpg and gpg-agent.
|
" Most distributions provide software to ease handling of gpg and gpg-agent.
|
||||||
" Examples are keychain or seahorse.
|
" Examples are keychain or seahorse.
|
||||||
"
|
"
|
||||||
|
" If there are specific actions that should take place when editing a
|
||||||
|
" GnuPG-managed buffer, an autocmd for the User event and GnuPG pattern can
|
||||||
|
" be defined. For example, the following will set 'textwidth' to 72 for all
|
||||||
|
" GnuPG-encrypted buffers:
|
||||||
|
"
|
||||||
|
" autocmd User GnuPG setl textwidth=72
|
||||||
|
"
|
||||||
|
" This will be triggered before any BufRead or BufNewFile autocmds, and
|
||||||
|
" therefore will not take precedence over settings specific to any filetype
|
||||||
|
" that may get set.
|
||||||
|
"
|
||||||
" Commands: {{{2
|
" Commands: {{{2
|
||||||
"
|
"
|
||||||
" :GPGEditRecipients
|
" :GPGEditRecipients
|
||||||
@@ -394,6 +405,11 @@ function s:GPGDecrypt(bufread)
|
|||||||
|
|
||||||
" File doesn't exist yet, so nothing to decrypt
|
" File doesn't exist yet, so nothing to decrypt
|
||||||
if empty(glob(filename))
|
if empty(glob(filename))
|
||||||
|
" Allow the user to define actions for GnuPG buffers
|
||||||
|
silent doautocmd User GnuPG
|
||||||
|
" call the autocommand for the file minus .gpg$
|
||||||
|
silent execute ':doautocmd BufNewFile ' . fnameescape(expand('<afile>:r'))
|
||||||
|
call s:GPGDebug(2, 'called BufNewFile autocommand for ' . fnameescape(expand('<afile>:r')))
|
||||||
|
|
||||||
" This is a new file, so force the user to edit the recipient list if
|
" This is a new file, so force the user to edit the recipient list if
|
||||||
" they open a new file and public keys are preferred
|
" they open a new file and public keys are preferred
|
||||||
@@ -524,9 +540,11 @@ function s:GPGBufReadPost()
|
|||||||
set undolevels=-1
|
set undolevels=-1
|
||||||
silent 1delete
|
silent 1delete
|
||||||
let &undolevels = levels
|
let &undolevels = levels
|
||||||
|
" Allow the user to define actions for GnuPG buffers
|
||||||
|
silent doautocmd User GnuPG
|
||||||
" call the autocommand for the file minus .gpg$
|
" call the autocommand for the file minus .gpg$
|
||||||
silent execute ':doautocmd BufReadPost ' . fnameescape(expand('<afile>:r'))
|
silent execute ':doautocmd BufReadPost ' . fnameescape(expand('<afile>:r'))
|
||||||
call s:GPGDebug(2, 'called autocommand for ' . fnameescape(expand('<afile>:r')))
|
call s:GPGDebug(2, 'called BufReadPost autocommand for ' . fnameescape(expand('<afile>:r')))
|
||||||
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGBufReadPost()")
|
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGBufReadPost()")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user