(defun epa-display-info (info)
(if epa-popup-info-window
(save-selected-window
- (unless epa-info-buffer
+ (unless (and epa-info-buffer (buffer-live-p epa-info-buffer))
(setq epa-info-buffer (generate-new-buffer "*Info*")))
(if (get-buffer-window epa-info-buffer)
(delete-window (get-buffer-window epa-info-buffer)))
Don't use this command in Lisp programs!"
(interactive "r")
- (let ((context (epg-make-context epa-protocol)))
+ (let ((context (epg-make-context epa-protocol))
+ plain)
(epg-context-set-progress-callback context
#'epa-progress-callback-function
"Verifying...")
- (epg-verify-string context
- (epa--encode-coding-string
- (buffer-substring start end)
- (or coding-system-for-write
- (get-text-property start
- 'epa-coding-system-used))))
+ (setq plain (epg-verify-string
+ context
+ (epa--encode-coding-string
+ (buffer-substring start end)
+ (or coding-system-for-write
+ (get-text-property start
+ 'epa-coding-system-used)))))
+ (if (y-or-n-p "Replace the original text? ")
+ (let ((inhibit-read-only t)
+ buffer-read-only)
+ (delete-region start end)
+ (goto-char start)
+ (insert plain))
+ (with-output-to-temp-buffer "*Temp*"
+ (set-buffer standard-output)
+ (insert plain)
+ (epa-info-mode)))
(if (epg-context-result-for context 'verify)
(epa-display-info (epg-verify-result-to-string
(epg-context-result-for context 'verify))))))
(save-restriction
(narrow-to-region start end)
(goto-char start)
- (let (armor-start armor-end)
+ (let (cleartext-start cleartext-end)
(while (re-search-forward "-----BEGIN PGP SIGNED MESSAGE-----$"
nil t)
- (setq armor-start (match-beginning 0))
+ (setq cleartext-start (match-beginning 0))
(unless (re-search-forward "^-----BEGIN PGP SIGNATURE-----$"
nil t)
(error "Invalid cleartext signed message"))
- (setq armor-end (re-search-forward
+ (setq cleartext-end (re-search-forward
"^-----END PGP SIGNATURE-----$"
nil t))
- (unless armor-end
- (error "No armor tail"))
- (epa-verify-region armor-start armor-end))))))
+ (unless cleartext-end
+ (error "No cleartext tail"))
+ (epa-verify-region cleartext-start cleartext-end))))))
(if (fboundp 'select-safe-coding-system)
(defalias 'epa--select-safe-coding-system 'select-safe-coding-system)