diff options
| author | Adam Sjøgren | 2012-12-25 23:49:35 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2012-12-25 23:49:35 +0100 |
| commit | 23dab7dca6ee4dbe4fb55f89f7291abb5cf932e7 (patch) | |
| tree | b15b5b49e61e2d7aa25b48d2e85becbb3b78f731 | |
| parent | ecfb998c179b004f515b0c4d8e98d53811a3b12a (diff) | |
| download | emacs-23dab7dca6ee4dbe4fb55f89f7291abb5cf932e7.tar.gz emacs-23dab7dca6ee4dbe4fb55f89f7291abb5cf932e7.zip | |
Display images from gpg signatures
* epg.el (epg-signature-to-string): Use new functions
epg-key-image, epg-key-image-to-string to find and display image
from key.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/epg.el | 28 |
2 files changed, 32 insertions, 2 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2181a6dde7e..73379a93027 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-12-25 Adam Sjøgren <asjo@koldfront.dk> | ||
| 2 | |||
| 3 | * epg.el (epg-signature-to-string): Use new functions | ||
| 4 | epg-key-image, epg-key-image-to-string to find and display image | ||
| 5 | from key. | ||
| 6 | |||
| 1 | 2012-12-24 Constantin Kulikov <zxnotdead@gmail.com> (tiny change) | 7 | 2012-12-24 Constantin Kulikov <zxnotdead@gmail.com> (tiny change) |
| 2 | 8 | ||
| 3 | * startup.el (initial-buffer-choice): Allow function as value | 9 | * startup.el (initial-buffer-choice): Allow function as value |
diff --git a/lisp/epg.el b/lisp/epg.el index 833a68d6e7e..b79c5df4165 100644 --- a/lisp/epg.el +++ b/lisp/epg.el | |||
| @@ -967,11 +967,34 @@ This function is for internal use only." | |||
| 967 | (setcdr entry value) | 967 | (setcdr entry value) |
| 968 | (epg-context-set-result context (cons (cons name value) result))))) | 968 | (epg-context-set-result context (cons (cons name value) result))))) |
| 969 | 969 | ||
| 970 | (defun epg-key-image (key-id) | ||
| 971 | "Return the image of a key, if any" | ||
| 972 | (let ((filename | ||
| 973 | (replace-regexp-in-string | ||
| 974 | "\n" "" | ||
| 975 | (shell-command-to-string | ||
| 976 | (concat "/usr/bin/gpg --photo-viewer 'echo %I >&2' --list-keys " | ||
| 977 | key-id " > /dev/null"))))) | ||
| 978 | (when (and (not (string-equal filename "")) | ||
| 979 | (file-exists-p filename)) | ||
| 980 | (create-image filename)))) | ||
| 981 | |||
| 982 | (defun epg-key-image-to-string (key-id) | ||
| 983 | "Return a string with the image of a key, if any" | ||
| 984 | (let* ((result "") | ||
| 985 | (key-image (epg-key-image key-id))) | ||
| 986 | (when key-image | ||
| 987 | (setq result " ") | ||
| 988 | (put-text-property 1 2 'display key-image result)) | ||
| 989 | result)) | ||
| 990 | |||
| 970 | (defun epg-signature-to-string (signature) | 991 | (defun epg-signature-to-string (signature) |
| 971 | "Convert SIGNATURE to a human readable string." | 992 | "Convert SIGNATURE to a human readable string." |
| 972 | (let* ((user-id (cdr (assoc (epg-signature-key-id signature) | 993 | (let* ((user-id (cdr (assoc (epg-signature-key-id signature) |
| 973 | epg-user-id-alist))) | 994 | epg-user-id-alist))) |
| 974 | (pubkey-algorithm (epg-signature-pubkey-algorithm signature))) | 995 | (pubkey-algorithm (epg-signature-pubkey-algorithm signature)) |
| 996 | (key-id (epg-signature-key-id signature)) | ||
| 997 | (key-image (epg-key-image-to-string key-id))) | ||
| 975 | (concat | 998 | (concat |
| 976 | (cond ((eq (epg-signature-status signature) 'good) | 999 | (cond ((eq (epg-signature-status signature) 'good) |
| 977 | "Good signature from ") | 1000 | "Good signature from ") |
| @@ -985,7 +1008,8 @@ This function is for internal use only." | |||
| 985 | "Signature made by revoked key ") | 1008 | "Signature made by revoked key ") |
| 986 | ((eq (epg-signature-status signature) 'no-pubkey) | 1009 | ((eq (epg-signature-status signature) 'no-pubkey) |
| 987 | "No public key for ")) | 1010 | "No public key for ")) |
| 988 | (epg-signature-key-id signature) | 1011 | key-id |
| 1012 | key-image | ||
| 989 | (if user-id | 1013 | (if user-id |
| 990 | (concat " " | 1014 | (concat " " |
| 991 | (if (stringp user-id) | 1015 | (if (stringp user-id) |