let g:loaded_signaturePlugin = 1
+" Function: SigFileReadable()
+" Purpose: Check if the signature file is readable
+"---------------------------------------------------------------------------
+func! SigFileReadable(sigfile)
+ let filename = expand(a:sigfile)
+ if !filereadable(filename)
+ echoerr "E484: Can't open file " . filename
+ return v:false
+ endif
+
+ return v:true
+endfunc
+
"---------------------------------------------------------------------------
" Function: AppendSignature()
" Purpose: Append a signature block at the end of message
" Purpose: Add a signature block if there isn't one already
"---------------------------------------------------------------------------
func! AddSignature(sigfile)
+ if !SigFileReadable(a:sigfile)
+ return v:false
+ endif
+
" Save current cursor position in mark 'z'
normal mz
" restore cursor position from mark 'z' if the mark is still valid
silent! normal `z
+
+ return v:true
endfunc
" Purpose: Replace all signature blocks in the message
"---------------------------------------------------------------------------
func! ReplaceAllSignatures(sigfile)
+ if !SigFileReadable(a:sigfile)
+ return v:false
+ endif
+
" Save current cursor position in mark 'z'
normal mz
" restore cursor position from mark 'z' if the mark is still valid
silent! normal `z
+
+ return v:true
endfunc
" Purpose: Replace only the last signature block in the message
"---------------------------------------------------------------------------
func! ReplaceLastSignature(sigfile)
+ if !SigFileReadable(a:sigfile)
+ return v:false
+ endif
+
" Save current cursor position in mark 'z'
normal mz
" restore cursor position from mark 'z' if the mark is still valid
silent! normal `z
+
+ return v:true
endfunc