sup-heliotrope/sup — pull request #7 by ericweikl (2013-02-10 19:09:32+00:00)
Title: Add new hook 'gpg-expand-keys'

sup does not support GPG groups, since GPGME ignores group definitions in gpg.conf by design. Therefore, there is no way e.g. to send encrypted mails to mailing lists using GPG groups.

If a gpg.conf contains group definitions like this:
```shell
group =KEYID001
group =KEYID002
group =KEYID001
group =KEYID002
group =KEYID003
```
When a mail is sent to bar@example.com, it should be encrypted for KEYID001, KEYID002 and KEYID003.

The new hook receives the list of current recipients (bar@example.com in the case above) and allows the user to swap recipients with other email addresses or key IDs. A simple hook to add group support could look like this:
```ruby
lookup_table = {}

`gpg --with-colons --list-config group 2> /dev/null`.each_line do |line|
email_and_keys = line.split(':')[2..3]
lookup_table[email_and_keys[0].gsub(/[<>]/, '')] = email_and_keys[1].strip.split(';')
end

recipients.map { |r| lookup_table.has_key?(r) ? lookup_table[r] : r }.flatten
```