(epg-sub-key-id (car (epg-key-sub-key-list
(widget-get widget :value))))))
+(if (fboundp 'encode-coding-string)
+ (defalias 'epa--encode-coding-string 'encode-coding-string)
+ (defalias 'epa--encode-coding-string 'identity))
+
+(if (fboundp 'decode-coding-string)
+ (defalias 'epa--decode-coding-string 'decode-coding-string)
+ (defalias 'epa--decode-coding-string 'identity))
+
(defun epa-keys-mode ()
"Major mode for `epa-list-keys'."
(kill-all-local-variables)
truncate-lines t
buffer-read-only t)
(use-local-map epa-keys-mode-map)
- (set-keymap-parent (current-local-map) widget-keymap)
(make-local-variable 'font-lock-defaults)
(setq font-lock-defaults '(epa-font-lock-keywords t))
;; In XEmacs, auto-initialization of font-lock is not effective
;; if buffer-file-name is not set.
(font-lock-set-defaults)
- (widget-setup)
(make-local-variable 'epa-exit-buffer-function)
(run-hooks 'epa-keys-mode-hook))
(or (next-single-property-change point 'epa-list-keys)
(point-max)))
(goto-char point))
- (epa-insert-keys context name mode)
- (epa-keys-mode))
+ (epa--insert-keys context name mode)
+ (epa-keys-mode)
+ (widget-setup)
+ (set-keymap-parent (current-local-map) widget-keymap))
(make-local-variable 'epa-list-keys-arguments)
(setq epa-list-keys-arguments (list name mode protocol))
(goto-char (point-min))
(pop-to-buffer (current-buffer)))
-(defun epa-insert-keys (context name mode)
+(defun epa--insert-keys (context name mode)
(save-excursion
(save-restriction
(narrow-to-region (point) (point))
(insert "\n\n")
(if names
(while names
- (epa-insert-keys context (car names) secret)
+ (epa--insert-keys context (car names) secret)
(if (get-text-property (point) 'epa-list-keys)
(epa-mark))
(goto-char (point-max))
(setq names (cdr names)))
(if secret
(progn
- (epa-insert-keys context nil secret)
+ (epa--insert-keys context nil secret)
(if (get-text-property (point) 'epa-list-keys)
(epa-mark)))
- (epa-insert-keys context nil nil)))
+ (epa--insert-keys context nil nil)))
(epa-keys-mode)
+ (widget-setup)
+ (set-keymap-parent (current-local-map) widget-keymap)
(setq epa-exit-buffer-function #'abort-recursive-edit)
(goto-char (point-min))
(pop-to-buffer (current-buffer)))
#'epa-progress-callback-function)
(message "Decrypting %s..." (file-name-nondirectory file))
(epg-decrypt-file context file plain)
- (message "Decrypting %s...done" (file-name-nondirectory file))
+ (message "Decrypting %s...wrote %s" (file-name-nondirectory file)
+ (file-name-nondirectory plain))
(if (epg-context-result-for context 'verify)
(epa-display-info (epg-verify-result-to-string
(epg-context-result-for context 'verify))))))
(epa-select-keys (epg-make-context) "Select keys for signing.
If no one is selected, default secret key is used. "
nil t)
- (if (y-or-n-p "Make a detached signature? ")
- 'detached
- (if (y-or-n-p "Make a cleartext signature? ")
- 'clear))))
+ (catch 'done
+ (while t
+ (message "Signature type (n,c,d,?) ")
+ (let ((c (read-char)))
+ (cond ((eq c ?c)
+ (throw 'done 'clear))
+ ((eq c ?d)
+ (throw 'done 'detached))
+ ((eq c ??)
+ (with-output-to-temp-buffer "*Help*"
+ (save-excursion
+ (set-buffer standard-output)
+ (insert "\
+n - Create a normal signature
+c - Create a cleartext signature
+d - Create a detached signature
+? - Show this help
+"))))
+ (t
+ (throw 'done nil))))))))
(let ((signature (concat file
(if (or epa-armor
(not (memq mode '(nil t normal detached))))
#'epa-progress-callback-function)
(message "Signing %s..." (file-name-nondirectory file))
(epg-sign-file context file signature mode)
- (message "Signing %s...done" (file-name-nondirectory file))))
+ (message "Signing %s...wrote %s" (file-name-nondirectory file)
+ (file-name-nondirectory signature))))
;;;###autoload
(defun epa-encrypt-file (file recipients)
#'epa-progress-callback-function)
(message "Encrypting %s..." (file-name-nondirectory file))
(epg-encrypt-file context file recipients cipher)
- (message "Encrypting %s...done" (file-name-nondirectory file))))
+ (message "Encrypting %s...wrote %s" (file-name-nondirectory file)
+ (file-name-nondirectory cipher))))
;;;###autoload
(defun epa-decrypt-region (start end)
(message "Decrypting...done")
(delete-region start end)
(goto-char start)
- (insert (decode-coding-string plain coding-system-for-read))
+ (insert (epa--decode-coding-string plain coding-system-for-read))
(if (epg-context-result-for context 'verify)
(epa-display-info (epg-verify-result-to-string
(epg-context-result-for context 'verify)))))))
(epg-context-set-progress-callback context
#'epa-progress-callback-function)
(epg-verify-string context
- (encode-coding-string
+ (epa--encode-coding-string
(buffer-substring start end)
coding-system-for-write))
(if (epg-context-result-for context 'verify)
(epa-select-keys (epg-make-context) "Select keys for signing.
If no one is selected, default secret key is used. "
nil t)
- (if (y-or-n-p "Make a detached signature? ")
- 'detached
- (if (y-or-n-p "Make a cleartext signature? ")
- 'clear))))
+ (catch 'done
+ (while t
+ (message "Signature type (n,c,d,?) ")
+ (let ((c (read-char)))
+ (cond ((eq c ?c)
+ (throw 'done 'clear))
+ ((eq c ?d)
+ (throw 'done 'detached))
+ ((eq c ??)
+ (with-output-to-temp-buffer "*Help*"
+ (save-excursion
+ (set-buffer standard-output)
+ (insert "\
+n - Create a normal signature
+c - Create a cleartext signature
+d - Create a detached signature
+? - Show this help
+"))))
+ (t
+ (throw 'done nil))))))))
(save-excursion
(let ((context (epg-make-context))
signature)
- (epg-context-set-armor context epa-armor)
- (epg-context-set-textmode context epa-textmode)
+ ;;(epg-context-set-armor context epa-armor)
+ (epg-context-set-armor context t)
+ ;;(epg-context-set-textmode context epa-textmode)
+ (epg-context-set-textmode context t)
(epg-context-set-signers context signers)
(epg-context-set-passphrase-callback context
#'epa-passphrase-callback-function)
#'epa-progress-callback-function)
(message "Signing...")
(setq signature (epg-sign-string context
- (encode-coding-string
+ (epa--encode-coding-string
(buffer-substring start end)
coding-system-for-write)
mode))
(message "Signing...done")
(delete-region start end)
- (insert (decode-coding-string signature coding-system-for-read)))))
+ (insert (epa--decode-coding-string signature coding-system-for-read)))))
;;;###autoload
(defun epa-encrypt-region (start end recipients)
(save-excursion
(let ((context (epg-make-context))
cipher)
- (epg-context-set-armor context epa-armor)
- (epg-context-set-textmode context epa-textmode)
+ ;;(epg-context-set-armor context epa-armor)
+ (epg-context-set-armor context t)
+ ;;(epg-context-set-textmode context epa-textmode)
+ (epg-context-set-textmode context t)
(epg-context-set-passphrase-callback context
#'epa-passphrase-callback-function)
(epg-context-set-progress-callback context
#'epa-progress-callback-function)
(message "Encrypting...")
(setq cipher (epg-encrypt-string context
- (encode-coding-string
+ (epa--encode-coding-string
(buffer-substring start end)
coding-system-for-write)
recipients))
(message "Exporting to %s...done" (file-name-nondirectory file))))
;;;###autoload
+(defun epa-insert-keys (keys)
+ "Insert selected KEYS after the point.
+
+Don't use this command in Lisp programs!"
+ (interactive
+ (list (epa-select-keys (epg-make-context) "Select keys to export. ")))
+ (let ((context (epg-make-context)))
+ ;;(epg-context-set-armor context epa-armor)
+ (epg-context-set-armor context t)
+ (insert (epg-export-keys-to-string context keys))))
+
+;;;###autoload
(defun epa-sign-keys (keys &optional local)
"Sign selected KEYS.
If a prefix-arg is specified, the signature is marked as non exportable.