Function: epa-sign-region
epa-sign-region is an autoloaded, interactive and byte-compiled
function defined in epa.el.gz.
Signature
(epa-sign-region START END SIGNERS MODE)
Documentation
Sign the current region between START and END by SIGNERS keys selected.
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 should be treated, you should consider
using the string based counterpart epg-sign-string, or the file
based counterpart epg-sign-file instead.
For example:
(let ((context (epg-make-context 'OpenPGP)))
(epg-sign-string
context
(encode-coding-string (buffer-substring start end) 'utf-8)))
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/epa.el.gz
;;;###autoload
(defun epa-sign-region (start end signers mode)
"Sign the current region between START and END by SIGNERS keys selected.
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 should be treated, you should consider
using the string based counterpart `epg-sign-string', or the file
based counterpart `epg-sign-file' instead.
For example:
\(let ((context (epg-make-context \\='OpenPGP)))
(epg-sign-string
context
(encode-coding-string (buffer-substring start end) \\='utf-8)))"
(declare (interactive-only t))
(interactive
(let ((verbose current-prefix-arg))
(setq epa-last-coding-system-specified
(or coding-system-for-write
(select-safe-coding-system
(region-beginning) (region-end))))
(list (region-beginning) (region-end)
(if verbose
(epa-select-keys (epg-make-context epa-protocol)
"Select keys for signing.
If no one is selected, default secret key is used. "
nil t))
(if verbose
(epa--read-signature-type)
'clear))))
(save-excursion
(let ((context (epg-make-context epa-protocol))
signature)
;;(setf (epg-context-armor context) epa-armor)
(setf (epg-context-armor context) t)
;;(setf (epg-context-textmode context) epa-textmode)
(setf (epg-context-textmode context) t)
(setf (epg-context-signers context) signers)
(epg-context-set-passphrase-callback context
#'epa-passphrase-callback-function)
(epg-context-set-progress-callback context
(cons
#'epa-progress-callback-function
"Signing..."))
(message "Signing...")
(condition-case error
(setq signature (epg-sign-string context
(encode-coding-string
(buffer-substring start end)
epa-last-coding-system-specified)
mode))
(error
(epa-display-error context)
(signal (car error) (cdr error))))
(message "Signing...done")
(delete-region start end)
(goto-char start)
(add-text-properties (point)
(progn
(insert (decode-coding-string
signature
(or coding-system-for-read
epa-last-coding-system-specified)))
(point))
(list 'epa-coding-system-used
epa-last-coding-system-specified
'front-sticky nil
'rear-nonsticky t)))))