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 53d086cb35
commit 0e86346933

View File

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