mirror of
https://github.com/Ascyii/vim-gnupg.git
synced 2026-01-01 06:14:24 -05:00
Add s:unencrypted function to consolidate "unencrypted buffer" check
Signed-off-by: James McCoy <jamessan@jamessan.com>
This commit is contained in:
@@ -246,6 +246,23 @@ function s:shellescape(s, ...)
|
|||||||
return escaped
|
return escaped
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" Function: s:unencrypted() {{{2
|
||||||
|
"
|
||||||
|
" Determines if the buffer corresponds to an existing, unencrypted file and,
|
||||||
|
" if so, warns the user that GPG functionality has been disabled.
|
||||||
|
"
|
||||||
|
" Returns: true if current buffer corresponds to an existing, unencrypted file
|
||||||
|
function! s:unencrypted()
|
||||||
|
if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
|
||||||
|
echohl GPGWarning
|
||||||
|
echom "File is not encrypted, all GPG functions disabled!"
|
||||||
|
echohl None
|
||||||
|
return 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
return 0
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Function: s:GPGInit(bufread) {{{2
|
" Function: s:GPGInit(bufread) {{{2
|
||||||
"
|
"
|
||||||
" initialize the plugin
|
" initialize the plugin
|
||||||
@@ -789,11 +806,7 @@ endfunction
|
|||||||
function s:GPGEditRecipients()
|
function s:GPGEditRecipients()
|
||||||
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEditRecipients()")
|
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEditRecipients()")
|
||||||
|
|
||||||
" guard for unencrypted files
|
if s:unencrypted()
|
||||||
if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
|
|
||||||
echohl GPGWarning
|
|
||||||
echom "File is not encrypted, all GPG functions disabled!"
|
|
||||||
echohl None
|
|
||||||
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditRecipients()")
|
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditRecipients()")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -912,11 +925,7 @@ endfunction
|
|||||||
function s:GPGFinishRecipientsBuffer()
|
function s:GPGFinishRecipientsBuffer()
|
||||||
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGFinishRecipientsBuffer()")
|
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGFinishRecipientsBuffer()")
|
||||||
|
|
||||||
" guard for unencrypted files
|
if s:unencrypted()
|
||||||
if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
|
|
||||||
echohl GPGWarning
|
|
||||||
echom "File is not encrypted, all GPG functions disabled!"
|
|
||||||
echohl None
|
|
||||||
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishRecipientsBuffer()")
|
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishRecipientsBuffer()")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -989,11 +998,7 @@ endfunction
|
|||||||
function s:GPGViewOptions()
|
function s:GPGViewOptions()
|
||||||
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGViewOptions()")
|
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGViewOptions()")
|
||||||
|
|
||||||
" guard for unencrypted files
|
if s:unencrypted()
|
||||||
if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
|
|
||||||
echohl GPGWarning
|
|
||||||
echom "File is not encrypted, all GPG functions disabled!"
|
|
||||||
echohl None
|
|
||||||
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewOptions()")
|
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGViewOptions()")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -1016,11 +1021,7 @@ endfunction
|
|||||||
function s:GPGEditOptions()
|
function s:GPGEditOptions()
|
||||||
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEditOptions()")
|
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGEditOptions()")
|
||||||
|
|
||||||
" guard for unencrypted files
|
if s:unencrypted()
|
||||||
if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
|
|
||||||
echohl GPGWarning
|
|
||||||
echom "File is not encrypted, all GPG functions disabled!"
|
|
||||||
echohl None
|
|
||||||
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditOptions()")
|
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGEditOptions()")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
@@ -1107,11 +1108,7 @@ endfunction
|
|||||||
function s:GPGFinishOptionsBuffer()
|
function s:GPGFinishOptionsBuffer()
|
||||||
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGFinishOptionsBuffer()")
|
call s:GPGDebug(3, ">>>>>>>> Entering s:GPGFinishOptionsBuffer()")
|
||||||
|
|
||||||
" guard for unencrypted files
|
if s:unencrypted()
|
||||||
if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
|
|
||||||
echohl GPGWarning
|
|
||||||
echom "File is not encrypted, all GPG functions disabled!"
|
|
||||||
echohl None
|
|
||||||
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishOptionsBuffer()")
|
call s:GPGDebug(3, "<<<<<<<< Leaving s:GPGFinishOptionsBuffer()")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user