GPGFinishRecipientsBuffer: Use the GPG ID, if present, to avoid repeat prompts

Whenever GPGFinishRecipientsBuffer is called, the buffer is processed to
convert names to IDs.  However, this was ignoring any existing ID information
in the buffer.  This meant that if a person had multiple keys, the user would
be prompted to disambiguate the keys after every :GPGEditRecipients session.

Parsing the ID out of the recipients buffer avoids the unnecessary prompting.

Signed-off-by: James McCoy <vega.james@gmail.com>
This commit is contained in:
James McCoy 2012-05-30 23:48:43 -04:00
parent b2b4e7525c
commit 9329403402

View File

@ -796,13 +796,13 @@ function s:GPGFinishRecipientsBuffer()
" delete the autocommand
autocmd! * <buffer>
" get the recipients from the scratch buffer
let recipients = []
let lines = getline(1,"$")
for recipient in lines
" delete all text after magic string
let recipient = substitute(recipient, s:GPGMagicString . ".*$", "", "")
let matches = matchlist(recipient, '^\(.\{-}\)\%(' . s:GPGMagicString . '(ID:\s\+\(' . s:keyPattern . '\)\s\+.*\)\=$')
let recipient = matches[2] ? matches[2] : matches[1]
" delete all spaces at beginning and end of the recipient
" also delete a '!' at the beginning of the recipient