Function: epa-verify-region

epa-verify-region is an autoloaded, interactive and byte-compiled function defined in epa.el.gz.

Signature

(epa-verify-region START END)

Documentation

Verify the current region between START and END.

Don't use this command in Lisp programs! Since this function operates on regions, it does some tricks such as coding-system detection and unibyte/multibyte conversion. If you are sure how the data in the region should be treated, you should consider using the string based counterpart epg-verify-string, or the file based counterpart epg-verify-file instead.

For example:

(let ((context (epg-make-context 'OpenPGP)))
  (decode-coding-string
    (epg-verify-string context (buffer-substring start end))
    'utf-8))

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/epa.el.gz
;;;###autoload
(defun epa-verify-region (start end)
  "Verify the current region between START and END.

Don't use this command in Lisp programs!
Since this function operates on regions, it does some tricks such
as coding-system detection and unibyte/multibyte conversion.  If
you are sure how the data in the region should be treated, you
should consider using the string based counterpart
`epg-verify-string', or the file based counterpart
`epg-verify-file' instead.

For example:

\(let ((context (epg-make-context \\='OpenPGP)))
  (decode-coding-string
    (epg-verify-string context (buffer-substring start end))
    \\='utf-8))"
  (declare (interactive-only t))
  (interactive "r")
  (let ((context (epg-make-context epa-protocol))
	plain)
    (setf (epg-context-progress-callback context)
	  (cons
	   #'epa-progress-callback-function
	   "Verifying..."))
    (message "Verifying...")
    (condition-case error
	(setq plain (epg-verify-string
		     context
		     (encode-coding-string
		      (buffer-substring start end)
		      (or coding-system-for-write
			  (get-text-property start 'epa-coding-system-used)))))
      (error
       (epa-display-error context)
       (signal (car error) (cdr error))))
    (message "Verifying...done")
    (setq plain (decode-coding-string
		 plain
		 (or coding-system-for-read
		     (get-text-property start 'epa-coding-system-used)
		     'undecided)))
    (unless (epg-context-result-for context 'verify)
      (error "Unable to verify region"))
    (if (or (eq epa-replace-original-text t)
            (and epa-replace-original-text
                 (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))))))