mirror of
https://github.com/Ascyii/vim-gnupg.git
synced 2026-01-01 06:14:24 -05:00
Maintain 'readonly' if it's already set
If the user is using "vim -R"/":view", then the opened buffer should have 'readonly' set, even if permissions would otherwise allow editing. Closes jamessan/vim-gnupg#67 Signed-off-by: James McCoy <jamessan@jamessan.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
" Name: gnupg.vim
|
" Name: gnupg.vim
|
||||||
" Last Change: 2016 Apr 24
|
" Last Change: 2016 Aug 25
|
||||||
" Maintainer: James McCoy <jamessan@jamessan.com>
|
" Maintainer: James McCoy <jamessan@jamessan.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.
|
||||||
@@ -599,7 +599,10 @@ function s:GPGDecrypt(bufread)
|
|||||||
1mark [
|
1mark [
|
||||||
$mark ]
|
$mark ]
|
||||||
let &undolevels = levels
|
let &undolevels = levels
|
||||||
let &readonly = filereadable(filename) && filewritable(filename) == 0
|
" The buffer should be readonly if
|
||||||
|
" - 'readonly' is already set (e.g., when using view/vim -R)
|
||||||
|
" - permissions don't allow writing
|
||||||
|
let &readonly = &readonly || (filereadable(filename) && filewritable(filename) == 0)
|
||||||
" call the autocommand for the file minus .gpg$
|
" call the autocommand for the file minus .gpg$
|
||||||
silent execute ':doautocmd BufReadPost ' . autocmd_filename
|
silent execute ':doautocmd BufReadPost ' . autocmd_filename
|
||||||
call s:GPGDebug(2, 'called BufReadPost autocommand for ' . autocmd_filename)
|
call s:GPGDebug(2, 'called BufReadPost autocommand for ' . autocmd_filename)
|
||||||
|
|||||||
Reference in New Issue
Block a user