From: ueno Date: Thu, 25 May 2006 05:10:17 +0000 (+0000) Subject: * epa.el (epa-decrypt-file): Display verify result if the message X-Git-Tag: epg-0_0_2~39 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=22b8bc18a04f596fc2864ac647a6ee886aaa52d7;p=elisp%2Fepg.git * epa.el (epa-decrypt-file): Display verify result if the message is signed. (epa-decrypt-region): New command. --- diff --git a/ChangeLog b/ChangeLog index 62d8d7a..ad5496e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-05-25 Daiki Ueno + + * epa.el (epa-decrypt-file): Display verify result if the message + is signed. + (epa-decrypt-region): New command. + 2006-05-11 Daiki Ueno * epa.el (epa-armor): New user option. diff --git a/epa.el b/epa.el index 703e056..b9524d7 100644 --- a/epa.el +++ b/epa.el @@ -485,7 +485,11 @@ If ARG is non-nil, mark the current line." (context (epg-make-context))) (message "Decrypting %s..." (file-name-nondirectory file)) (epg-decrypt-file context file plain) - (message "Decrypting %s...done" (file-name-nondirectory file)))) + (message "Decrypting %s...done" (file-name-nondirectory file)) + (if (epg-context-result-for context 'verify) + (message "%s" + (epg-verify-result-to-string + (epg-context-result-for context 'verify)))))) ;;;###autoload (defun epa-verify-file (file) @@ -605,6 +609,41 @@ If LOCAL is non-nil, the signature is marked as non exportable." (epg-sign-keys context keys local) (message "Signing keys...done"))) +;;;###autoload +(defun epa-decrypt-region (start end) + "Decrypt OpenPGP armors in the current region between START and END." + (interactive "r") + (save-excursion + (save-restriction + (narrow-to-region start end) + (goto-char start) + (let (armor-start armor-end charset context plain coding-system) + (while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t) + (setq armor-start (match-beginning 0) + armor-end (re-search-forward "^-----END PGP MESSAGE-----$" + nil t)) + (unless armor-end + (error "No armor tail")) + (goto-char armor-start) + (if (re-search-forward "^Charset: \\(.*\\)" nil t) + (setq charset (match-string 1))) + (setq context (epg-make-context) + plain (epg-decrypt-string + context + (buffer-substring armor-start armor-end))) + (delete-region armor-start armor-end) + (goto-char armor-start) + (if coding-system-for-read + (setq coding-system coding-system-for-read) + (if charset + (setq coding-system (intern (downcase charset))) + (setq coding-system 'utf-8))) + (insert (decode-coding-string plain coding-system)) + (if (epg-context-result-for context 'verify) + (message "%s" + (epg-verify-result-to-string + (epg-context-result-for context 'verify))))))))) + (provide 'epa) ;;; epa.el ends here