* epa.el (epa-keys-mode-map): Bind epa-decrypt-file,
[elisp/epg.git] / epa-dired.el
1 (require 'epa)
2 (require 'dired)
3
4 (defvar epa-dired-map
5   (let ((keymap (make-sparse-keymap)))
6     (define-key keymap "d" 'epa-dired-do-decrypt)
7     (define-key keymap "v" 'epa-dired-do-verify)
8     (define-key keymap "s" 'epa-dired-do-sign)
9     (define-key keymap "e" 'epa-dired-do-encrypt)
10     keymap))
11
12 (fset 'epa-dired-prefix epa-dired-map)
13
14 (defun epa-dired-mode-hook ()
15   (define-key dired-mode-map ":" 'epa-dired-prefix))
16
17 (defun epa-dired-do-decrypt ()
18   (interactive)
19   (let ((file-list (dired-get-marked-files)))
20     (while file-list
21       (epa-decrypt-file (car file-list))
22       (setq file-list (cdr file-list)))))
23
24 (defun epa-dired-do-verify ()
25   (interactive)
26   (let ((file-list (dired-get-marked-files)))
27     (while file-list
28       (epa-verify-file (car file-list))
29       (setq file-list (cdr file-list)))))
30
31 (defun epa-dired-do-sign (&optional detached)
32   (interactive "P")
33   (let ((file-list (dired-get-marked-files)))
34     (while file-list
35       (epa-sign-file (expand-file-name (car file-list)) detached)
36       (setq file-list (cdr file-list)))))
37
38 (defun epa-dired-do-encrypt ()
39   (interactive)
40   (let ((file-list (dired-get-marked-files)))
41     (while file-list
42       (epa-encrypt-file
43        (car file-list)
44        (mapcar (lambda (key)
45                  (epg-sub-key-id
46                   (car (epg-key-sub-key-list key))))
47                (epa-select-keys "Select recipents for encryption.
48 If no one is selected, symmetric encryption will be performed.  ")))
49       (setq file-list (cdr file-list)))))
50
51 (provide 'epa-dired)
52
53 ;;; epa-dired.el ends here