From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/82731 Path: news.gmane.org!not-for-mail From: asjo@koldfront.dk (Adam =?iso-8859-1?Q?Sj=F8gren?=) Newsgroups: gmane.emacs.gnus.general Subject: Re: Displaying picture from PGP key if present? Date: Tue, 25 Dec 2012 23:33:38 +0100 Organization: koldfront - analysis & revolution, Copenhagen, Denmark Message-ID: <87sj6t7oe5.fsf@topper.koldfront.dk> References: <87ehirwgjq.fsf@topper.koldfront.dk> <87ip7quzk3.fsf@gnus.org> <87mwx2s62p.fsf@topper.koldfront.dk> <87vcbqtk8q.fsf@gnus.org> <87ip7qs5fm.fsf@topper.koldfront.dk> <878v8mtjbg.fsf@gnus.org> <874njas1yf.fsf@topper.koldfront.dk> <87623qb5vl.fsf@gnus.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1356474867 28333 80.91.229.3 (25 Dec 2012 22:34:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 25 Dec 2012 22:34:27 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M30997@lists.math.uh.edu Tue Dec 25 23:34:43 2012 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tnd58-0003A8-FN for ding-account@gmane.org; Tue, 25 Dec 2012 23:34:42 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1Tnd4N-00019J-Gr; Tue, 25 Dec 2012 16:33:55 -0600 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1Tnd4K-000190-FP for ding@lists.math.uh.edu; Tue, 25 Dec 2012 16:33:52 -0600 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1Tnd4I-0008Mh-Fb for ding@lists.math.uh.edu; Tue, 25 Dec 2012 16:33:51 -0600 Original-Received: from plane.gmane.org ([80.91.229.3]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1Tnd4G-0005VN-9J for ding@gnus.org; Tue, 25 Dec 2012 23:33:48 +0100 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Tnd4S-0002ej-1g for ding@gnus.org; Tue, 25 Dec 2012 23:34:00 +0100 Original-Received: from 2505ds5-by.0.fullrate.dk ([89.150.142.116]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 Dec 2012 23:34:00 +0100 Original-Received: from asjo by 2505ds5-by.0.fullrate.dk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 Dec 2012 23:34:00 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 74 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 2505ds5-by.0.fullrate.dk OpenPGP: id=21BDE416; url=http://asjo.koldfront.dk/gpg.asc Mail-Follow-Up-To: never X-Now-Playing: Buffalo stance [Sukka mix], Raw like sushi (Neneh Cherry) X-Face: )qY&CseJ?.:=8F#^~GcSA?F=9eu'{KAFfL1C3/A&:nE?PW\i65"ba0NS)97,Q(^@xk}n4Ou rPuR#V8I(J_@~H($[ym:`K_+]*kjvW>xH5jbgLBVFGXY:(#4P>zVBklLbdL&XxL\M)%T}3S/IS9lMJ ^St'=VZBR Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:82731 Archived-At: On Tue, 25 Dec 2012 14:47:42 +0100, Lars wrote: > You can `propertize' the string with an 'display' property that contains > an image. Thanks, that was the push I needed. Although my start of a solution is somewhat hackish in the way that I get the image; I should probably read some more of epg.el to find some code that does the "shell-command-to-string" bit in the appropriate way. Anyway, here is what I got: Show image from PGP key, if present, in 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. --- lisp/epg.el | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lisp/epg.el b/lisp/epg.el index b0e01bc..d711c28 100644 --- a/lisp/epg.el +++ b/lisp/epg.el @@ -966,11 +966,28 @@ This function is for internal use only." (setcdr entry value) (epg-context-set-result context (cons (cons name value) result))))) +(defun epg-key-image (key-id) + "Return the image of a key, if any" + (let ((filename (replace-regexp-in-string "\n" "" (shell-command-to-string (concat "/usr/bin/gpg --photo-viewer 'echo %I >&2' --list-keys " key-id " > /dev/null"))))) + (when (and (not (string-equal filename "")) (file-exists-p filename)) + (create-image filename)))) + +(defun epg-key-image-to-string (key-id) + "Return a string with the image of a key, if any" + (let* ((result "") + (key-image (epg-key-image key-id))) + (when key-image + (setq result " ") + (put-text-property 1 2 'display key-image result)) + result)) + (defun epg-signature-to-string (signature) "Convert SIGNATURE to a human readable string." (let* ((user-id (cdr (assoc (epg-signature-key-id signature) epg-user-id-alist))) - (pubkey-algorithm (epg-signature-pubkey-algorithm signature))) + (pubkey-algorithm (epg-signature-pubkey-algorithm signature)) + (key-id (epg-signature-key-id signature)) + (key-image (epg-key-image-to-string key-id))) (concat (cond ((eq (epg-signature-status signature) 'good) "Good signature from ") @@ -984,7 +1001,8 @@ This function is for internal use only." "Signature made by revoked key ") ((eq (epg-signature-status signature) 'no-pubkey) "No public key for ")) - (epg-signature-key-id signature) + key-id + key-image (if user-id (concat " " (if (stringp user-id) -- 1.7.10.4 -- "Boy, I love summer vacation. Adam Sjøgren I can feel my brain beginning to atrophy already." asjo@koldfront.dk