Fix merge mistake.
[emacs.git] / lisp / epa-dired.el
bloba02081bd9df61d143f5d4e69a18f85978af28df2
1 ;;; epa-dired.el --- the EasyPG Assistant, dired extension
2 ;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Keywords: PGP, GnuPG
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 3, or (at your option)
12 ;; any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
24 ;;; Code:
26 (require 'epa)
27 (require 'dired)
29 (defvar epa-dired-mode-map
30 (let ((keymap (make-sparse-keymap)))
31 (define-key keymap ":d" 'epa-dired-do-decrypt)
32 (define-key keymap ":v" 'epa-dired-do-verify)
33 (define-key keymap ":s" 'epa-dired-do-sign)
34 (define-key keymap ":e" 'epa-dired-do-encrypt)
35 keymap))
37 (defvar epa-dired-mode-hook nil)
38 (defvar epa-dired-mode-on-hook nil)
39 (defvar epa-dired-mode-off-hook nil)
41 ;;;###autoload
42 (define-minor-mode epa-dired-mode
43 "A minor-mode for encrypt/decrypt files with Dired."
44 nil " epa-dired" epa-dired-mode-map)
46 (defun epa-dired-do-decrypt ()
47 "Decrypt marked files."
48 (interactive)
49 (let ((file-list (dired-get-marked-files)))
50 (while file-list
51 (epa-decrypt-file (expand-file-name (car file-list)))
52 (setq file-list (cdr file-list)))
53 (revert-buffer)))
55 (defun epa-dired-do-verify ()
56 "Verify marked files."
57 (interactive)
58 (let ((file-list (dired-get-marked-files)))
59 (while file-list
60 (epa-verify-file (expand-file-name (car file-list)))
61 (setq file-list (cdr file-list)))))
63 (defun epa-dired-do-sign ()
64 "Sign marked files."
65 (interactive)
66 (let ((file-list (dired-get-marked-files)))
67 (while file-list
68 (epa-sign-file
69 (expand-file-name (car file-list))
70 (epa-select-keys (epg-make-context) "Select keys for signing.
71 If no one is selected, default secret key is used. "
72 nil t)
73 (y-or-n-p "Make a detached signature? "))
74 (setq file-list (cdr file-list)))
75 (revert-buffer)))
77 (defun epa-dired-do-encrypt ()
78 "Encrypt marked files."
79 (interactive)
80 (let ((file-list (dired-get-marked-files)))
81 (while file-list
82 (epa-encrypt-file
83 (expand-file-name (car file-list))
84 (epa-select-keys (epg-make-context) "Select recipents for encryption.
85 If no one is selected, symmetric encryption will be performed. "))
86 (setq file-list (cdr file-list)))
87 (revert-buffer)))
89 ;;;###autoload
90 (define-minor-mode epa-global-dired-mode
91 "Minor mode to hook EasyPG into Dired."
92 :global t :init-value nil :group 'epa-dired :version "23.1"
93 (remove-hook 'dired-mode-hook 'epa-dired-mode)
94 (if epa-global-dired-mode
95 (add-hook 'dired-mode-hook 'epa-dired-mode)))
97 (provide 'epa-dired)
99 ;; arch-tag: 2025700b-48d0-4684-bc94-228ad1f8e9ff
100 ;;; epa-dired.el ends here