From f54cd3b6ad2144fe5bce749ae189c292c3e0eef1 Mon Sep 17 00:00:00 2001 From: ueno Date: Tue, 30 Jan 2007 05:40:43 +0000 Subject: [PATCH] * epg.el (epg-last-status): New variable. (epg--process-filter): Set epg-last-status after calling a status handler. (epg--prompt-GET_BOOL): New function. (epg--prompt-GET_BOOL-untrusted_key.override): New function. (epg--status-GET_BOOL): Call epg--prompt-GET_BOOL-* instead of y-or-n-p. --- ChangeLog | 10 ++++++++++ epg.el | 26 ++++++++++++++++++++------ 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b00926..7de5ecc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-01-30 Daiki Ueno + + * epg.el (epg-last-status): New variable. + (epg--process-filter): Set epg-last-status after calling a status + handler. + (epg--prompt-GET_BOOL): New function. + (epg--prompt-GET_BOOL-untrusted_key.override): New function. + (epg--status-GET_BOOL): Call epg--prompt-GET_BOOL-* instead of + y-or-n-p. + 2007-01-29 Daiki Ueno * EasyPG: Version 0.0.10 released. diff --git a/epg.el b/epg.el index 006a68d..89a78b8 100644 --- a/epg.el +++ b/epg.el @@ -33,6 +33,7 @@ (defvar epg-user-id-alist nil "An alist mapping from key ID to user ID.") +(defvar epg-last-status nil) (defvar epg-read-point nil) (defvar epg-process-filter-running nil) (defvar epg-pending-status-list nil) @@ -1143,7 +1144,8 @@ This function is for internal use only." (setq epg-pending-status-list nil)) (if (and symbol (fboundp symbol)) - (funcall symbol epg-context string)))) + (funcall symbol epg-context string)) + (setq epg-last-status (cons status string)))) (forward-line) (setq epg-read-point (point)))) (setq epg-process-filter-running nil)))))) @@ -1256,13 +1258,25 @@ This function is for internal use only." (if encoded-passphrase-with-new-line (epg--clear-string encoded-passphrase-with-new-line)))))) +(defun epg--prompt-GET_BOOL (context string) + (let ((entry (assoc string epg-prompt-alist))) + (y-or-n-p (if entry (cdr entry) (concat string "? "))))) + +(defun epg--prompt-GET_BOOL-untrusted_key.override (context string) + (if (and (equal (car epg-last-status) "USERID_HINT") + (string-match "\\`\\([^ ]+\\) \\(.*\\)" (cdr epg-last-status))) + (y-or-n-p (format "Untrusted key %s %s. Trust this key anyway? " + (match-string 1 string) + (match-string 2 string))))) + (defun epg--status-GET_BOOL (context string) - (let ((entry (assoc string epg-prompt-alist)) - inhibit-quit) + (let (inhibit-quit) (condition-case nil - (if (y-or-n-p (if entry (cdr entry) (concat string "? "))) - (process-send-string (epg-context-process context) "y\n") - (process-send-string (epg-context-process context) "n\n")) + (if (funcall (or (intern-soft (concat "epg--prompt-GET_BOOL-" string)) + #'epg--prompt-GET_BOOL) + context string) + (process-send-string (epg-context-process context) "y\n") + (process-send-string (epg-context-process context) "n\n")) (quit (epg-context-set-result-for context 'error -- 1.7.10.4