- recipients)
- (if recipients
- (mapcar
- (lambda (recipient)
- (setq recipient-key
- (epa-mail--find-usable-key
- (epg-list-keys
- (epg-make-context epa-protocol)
- (if (string-match "@" recipient)
- (concat "<" recipient ">")
- recipient))
- 'encrypt))
- (unless (or recipient-key
- (y-or-n-p
- (format
- "No public key for %s; skip it? "
- recipient)))
- (error "No public key for %s" recipient))
- recipient-key)
- recipients)))
- (setq sign (if verbose (y-or-n-p "Sign? ")))
- (if sign
- (epa-select-keys context
- "Select keys for signing. "))))))
- (epa-encrypt-region start end recipients sign signers))
+ (epa-mail-default-recipients))
+ t))
+ (and verbose (y-or-n-p "Sign? ")
+ (epa-select-keys context
+ "Select keys for signing. ")))))
+ (let (start recipient-keys default-recipients)
+ (save-excursion
+ (setq recipient-keys
+ (cond ((eq recipients t)
+ nil)
+ (recipients recipients)
+ (t
+ (setq default-recipients
+ (epa-mail-default-recipients))
+ ;; Convert recipients to keys.
+ (apply
+ 'nconc
+ (mapcar
+ (lambda (recipient)
+ (let ((recipient-key
+ (epa-mail--find-usable-key
+ (epg-list-keys
+ (epg-make-context epa-protocol)
+ (if (string-match "@" recipient)
+ (concat "<" recipient ">")
+ recipient))
+ 'encrypt)))
+ (unless (or recipient-key
+ (y-or-n-p
+ (format
+ "No public key for %s; skip it? "
+ recipient)))
+ (error "No public key for %s" recipient))
+ (if recipient-key (list recipient-key))))
+ default-recipients)))))
+
+ (goto-char (point-min))
+ (if (search-forward mail-header-separator nil t)
+ (forward-line))
+ (setq start (point))
+
+ (setq epa-last-coding-system-specified
+ (or coding-system-for-write
+ (epa--select-safe-coding-system (point) (point-max)))))
+
+ ;; Don't let some read-only text stop us from encrypting.
+ (let ((inhibit-read-only t))
+ (epa-encrypt-region start (point-max) recipient-keys signers signers))))