-(defun epa-command-next-line (count)
- "Same as next-line except that if you are at the beginning of buffer,
-you will be jumped to the first secret key."
- (interactive "p")
- (if (get-text-property (point) 'epa-key-id)
- (next-line count)
- (let ((point (next-single-property-change (point) 'epa-key-id)))
- (if (and point
- (get-text-property point 'epa-key-id))
- (goto-char point)))))
-
-(defun epa-command-encrypt-file (plain cipher recipients sign)
- "Encrypt a file PLAIN for RECIPIENTS."
- (interactive
- (save-excursion
- (set-buffer epa-buffer)
- (goto-char (point-min))
- (let (plain recipients)
- (while (re-search-forward "^\\*" nil t)
- (unless (get-text-property (point) 'epa-key-secret)
- (setq recipients (cons (get-text-property (point) 'epa-key-id)
- recipients))))
- (list (setq plain (expand-file-name (read-file-name "Plain file: ")))
- (expand-file-name
- (read-file-name (format "Cipher file (default %s.gpg) "
- (file-name-nondirectory plain))
- (file-name-directory plain)
- (concat plain ".gpg")))
- recipients
- current-prefix-arg))))
- (message "Encrypting %s..." (file-name-nondirectory plain))
- (epg-encrypt-file (epg-make-context)
- plain
- recipients
- (expand-file-name cipher)
- sign)
- (message "Encrypting %s...done" (file-name-nondirectory plain)))
-
-(defun epa-command-sign-file (plain signature detached signers)
- "Sign a file PLAIN."
- (interactive
- (save-excursion
- (set-buffer epa-buffer)
- (goto-char (point-min))
- (let ((extension (if current-prefix-arg ".sig" ".gpg"))
- plain signers)
- (while (re-search-forward "^\\*" nil t)
- (if (get-text-property (point) 'epa-key-secret)
- (setq signers (cons (get-text-property (point) 'epa-key-id)
- signers))))
-
- (list (setq plain (expand-file-name (read-file-name "Plain file: ")))
- (expand-file-name
- (read-file-name (format "Signature file (default %s%s) "
- (file-name-nondirectory plain)
- extension)
- (file-name-directory plain)
- (concat plain extension)))
- current-prefix-arg
- signers))))
- (let ((context (epg-make-context)))
- (epg-context-set-signers context signers)
- (message "Signing %s..." (file-name-nondirectory plain))
- (epg-sign-file context
- plain
- signature
- (if detached 'detached))
- (message "Signing %s...done" (file-name-nondirectory plain))))
-