(epa-file-handler): Put 'safe-magic and 'operations properties.
* epa.el (epa-global-minor-modes, epa-mode, epa-menu)
(epa-menu-items): Remove.
* epa-dired.el (epa-dired-do-decrypt, epa-dired-do-verify)
(epa-dired-do-sign, epa-dired-do-encrypt): Add autoload cookie.
(epa-dired-mode, epa-global-dired-mode): Remove.
* dired.el (dired-mode-map): Bind encryption/decryption commands.
* menu-bar.el (menu-bar-encryption-decryption-menu): New menu item.
* files.el (insert-file-contents-literally): Inhibit epa-file-handler.
+2008-04-27 Daiki Ueno <ueno@unixuser.org>
+
+ * epa-file.el (auto-encryption-mode): Rename from epa-file-mode.
+ (epa-file-handler): Put 'safe-magic and 'operations properties.
+
+ * epa.el (epa-global-minor-modes, epa-mode, epa-menu)
+ (epa-menu-items): Remove.
+
+ * epa-dired.el (epa-dired-do-decrypt, epa-dired-do-verify)
+ (epa-dired-do-sign, epa-dired-do-encrypt): Add autoload cookie.
+ (epa-dired-mode, epa-global-dired-mode): Remove.
+
+ * dired.el (dired-mode-map): Bind encryption/decryption commands.
+
+ * menu-bar.el (menu-bar-encryption-decryption-menu): New menu item.
+
+ * files.el (insert-file-contents-literally): Inhibit epa-file-handler.
+
2008-04-27 Glenn Morris <rgm@gnu.org>
* textmodes/reftex-global.el (reftex-isearch-switch-to-next-file):
(define-key map "\C-tf" 'image-dired-mark-tagged-files)
(define-key map "\C-t\C-t" 'image-dired-dired-insert-marked-thumbs)
(define-key map "\C-te" 'image-dired-dired-edit-comment-and-tags)
+ ;; encryption and decryption (epa-dired)
+ (define-key map ":d" 'epa-dired-do-decrypt)
+ (define-key map ":v" 'epa-dired-do-verify)
+ (define-key map ":s" 'epa-dired-do-sign)
+ (define-key map ":e" 'epa-dired-do-encrypt)
;; Make menu bar items.
(define-key map [menu-bar immediate]
(cons "Immediate" (make-sparse-keymap "Immediate")))
+ (define-key map
+ [menu-bar immediate epa-dired-do-decrypt]
+ '(menu-item "Decrypt" epa-dired-do-decrypt
+ :help "Decrypt file at cursor"))
+
+ (define-key map
+ [menu-bar immediate epa-dired-do-verify]
+ '(menu-item "Verify" epa-dired-do-verify
+ :help "Verify digital signature of file at cursor"))
+
+ (define-key map
+ [menu-bar immediate epa-dired-do-sign]
+ '(menu-item "Sign" epa-dired-do-sign
+ :help "Create digital signature of file at cursor"))
+
+ (define-key map
+ [menu-bar immediate epa-dired-do-encrypt]
+ '(menu-item "Encrypt" epa-dired-do-encrypt
+ :help "Encrypt file at cursor"))
+
+ (define-key map [menu-bar immediate dashes-4]
+ '("--"))
+
(define-key map
[menu-bar immediate image-dired-dired-display-external]
'(menu-item "Display Image Externally" image-dired-dired-display-external
(require 'epa)
(require 'dired)
-(defvar epa-dired-mode-map
- (let ((keymap (make-sparse-keymap)))
- (define-key keymap ":d" 'epa-dired-do-decrypt)
- (define-key keymap ":v" 'epa-dired-do-verify)
- (define-key keymap ":s" 'epa-dired-do-sign)
- (define-key keymap ":e" 'epa-dired-do-encrypt)
- keymap))
-
-(defvar epa-dired-mode-hook nil)
-(defvar epa-dired-mode-on-hook nil)
-(defvar epa-dired-mode-off-hook nil)
-
;;;###autoload
-(define-minor-mode epa-dired-mode
- "A minor-mode for encrypt/decrypt files with Dired."
- nil " epa-dired" epa-dired-mode-map)
-
(defun epa-dired-do-decrypt ()
"Decrypt marked files."
(interactive)
(setq file-list (cdr file-list)))
(revert-buffer)))
+;;;###autoload
(defun epa-dired-do-verify ()
"Verify marked files."
(interactive)
(epa-verify-file (expand-file-name (car file-list)))
(setq file-list (cdr file-list)))))
+;;;###autoload
(defun epa-dired-do-sign ()
"Sign marked files."
(interactive)
(setq file-list (cdr file-list)))
(revert-buffer)))
+;;;###autoload
(defun epa-dired-do-encrypt ()
"Encrypt marked files."
(interactive)
(setq file-list (cdr file-list)))
(revert-buffer)))
-;;;###autoload
-(define-minor-mode epa-global-dired-mode
- "Minor mode to hook EasyPG into Dired."
- :global t :init-value nil :group 'epa-dired :version "23.1"
- (remove-hook 'dired-mode-hook 'epa-dired-mode)
- (if epa-global-dired-mode
- (add-hook 'dired-mode-hook 'epa-dired-mode)))
-
(provide 'epa-dired)
;; arch-tag: 2025700b-48d0-4684-bc94-228ad1f8e9ff
(defun epa-file-handler (operation &rest args)
(save-match-data
(let ((op (get operation 'epa-file)))
- (if op
+ (if (and op
+ (if (and (eq operation 'insert-file-contents)
+
+ (y-or-n-p ""
(apply op args)
(epa-file-run-real-handler operation args)))))
(message "`epa-file' already enabled")
(setq file-name-handler-alist
(cons epa-file-handler file-name-handler-alist))
- (add-hook 'find-file-hooks 'epa-file-find-file-hook)
+ (add-hook 'find-file-hook 'epa-file-find-file-hook)
(setq auto-mode-alist (cons epa-file-auto-mode-alist-entry auto-mode-alist))
(message "`epa-file' enabled")))
(progn
(setq file-name-handler-alist
(delq epa-file-handler file-name-handler-alist))
- (remove-hook 'find-file-hooks 'epa-file-find-file-hook)
+ (remove-hook 'find-file-hook 'epa-file-find-file-hook)
(setq auto-mode-alist (delq epa-file-auto-mode-alist-entry
auto-mode-alist))
(message "`epa-file' disabled"))
(message "`epa-file' already disabled")))
;;;###autoload
-(define-minor-mode epa-file-mode
+(define-minor-mode auto-encryption-mode
"Toggle automatic file encryption and decryption.
With prefix argument ARG, turn auto encryption on if positive, else off.
Return the new status of auto encryption (non-nil means on)."
- :global t :init-value nil :group 'epa-file :version "23.1"
+ :global t :init-value t :group 'epa-file :version "23.1"
(setq file-name-handler-alist
(delq epa-file-handler file-name-handler-alist))
(remove-hook 'find-file-hooks 'epa-file-find-file-hook)
(setq auto-mode-alist (delq epa-file-auto-mode-alist-entry
auto-mode-alist))
- (when epa-file-mode
+ (when auto-encryption-mode
(setq file-name-handler-alist
(cons epa-file-handler file-name-handler-alist))
- (add-hook 'find-file-hooks 'epa-file-find-file-hook)
+ (add-hook 'find-file-hook 'epa-file-find-file-hook)
+ (add-hook 'find-file-not-found-functions
+ 'epa-file-find-file-not-found-functions)
(setq auto-mode-alist (cons epa-file-auto-mode-alist-entry
auto-mode-alist))))
+(put 'epa-file-handler 'safe-magic t)
+(put 'epa-file-handler 'operations '(write-region insert-file-contents))
+
(provide 'epa-file)
;; arch-tag: 5715152f-0eb1-4dbc-9008-07098775314d
:type 'integer
:group 'epa)
-(defcustom epa-global-minor-modes '(epa-global-dired-mode
- epa-global-mail-mode
- epa-file-mode)
- "Globally defined minor modes to hook into other modes."
- :type '(repeat symbol)
- :group 'epa)
-
(defgroup epa-faces nil
"Faces for epa-mode."
:version "23.1"
(define-key keymap "q" 'delete-window)
keymap))
-(defvar epa-menu nil)
-
-(defconst epa-menu-items
- '("Encryption/Decryption"
- ("Decrypt"
- ["File" epa-decrypt-file
- :help "Decrypt a file"]
- ["Region" epa-decrypt-region
- :help "Decrypt the current region"])
- ("Verify"
- ["File" epa-verify-file
- :help "Verify digital signature of a file"]
- ["Region" epa-verify-region
- :help "Verify digital signature of the current region"])
- ("Sign"
- ["File" epa-sign-file
- :help "Create digital signature of a file"]
- ["Region" epa-sign-region
- :help "Create digital signature of the current region"])
- ("Encrypt"
- ["File" epa-encrypt-file
- :help "Encrypt a file"]
- ["Region" epa-encrypt-region
- :help "Encrypt the current region"])
- "----"
- ["Browse keyring" epa-list-keys
- :help "Browse your public keyring"]
- ("Import keys"
- ["File" epa-import-keys
- :help "Import public keys from a file"]
- ["Region" epa-import-keys-region
- :help "Import public keys from the current region"])
- ("Export key"
- ["To a File" epa-export-keys
- :help "Export public keys to a file"]
- ["To a Buffer" epa-insert-keys
- :help "Insert public keys after the current point"])))
-
(defvar epa-exit-buffer-function #'bury-buffer)
(define-widget 'epa-key 'push-button
;; (message "Signing keys...done")))
;; (make-obsolete 'epa-sign-keys "Do not use.")
-;;;###autoload
-(define-minor-mode epa-mode
- "Minor mode to hook EasyPG into various modes.
-See `epa-global-minor-modes'."
- :global t :init-value nil :group 'epa :version "23.1"
- (unless epa-menu
- (easy-menu-define epa-menu nil "EasyPG Assistant global menu"
- epa-menu-items))
- (easy-menu-remove-item nil '("Tools") "Encryption/Decryption")
- (if epa-mode
- (easy-menu-add-item nil '("Tools") epa-menu))
- (let ((modes epa-global-minor-modes)
- symbol)
- (while modes
- (setq symbol (car modes))
- (if (and symbol
- (fboundp symbol))
- (funcall symbol epa-mode)
- (message "`%S' not found" (car modes)))
- (setq modes (cdr modes)))))
-
(provide 'epa)
;; arch-tag: 38d20ced-20d5-4137-b17a-f206335423d7
(symbol-function 'find-buffer-file-type)
nil))
(inhibit-file-name-handlers
- (append '(jka-compr-handler image-file-handler)
+ (append '(jka-compr-handler image-file-handler epa-file-handler)
inhibit-file-name-handlers))
(inhibit-file-name-operation 'insert-file-contents))
(unwind-protect
(known (assq read-mail-command known-rmail-commands)))
(if known (cdr known) (symbol-name read-mail-command))))
+(defvar menu-bar-encryption-decryption-menu
+ (make-sparse-keymap "Encryption/Decryption"))
+
+(define-key menu-bar-tools-menu [encryption-decryption]
+ (list 'menu-item "Encryption/Decryption" menu-bar-encryption-decryption-menu))
+
+(define-key menu-bar-tools-menu [separator-encryption-decryption]
+ '("--"))
+
+(define-key menu-bar-encryption-decryption-menu [insert-keys]
+ '(menu-item "Insert Keys" epa-insert-keys
+ :help "Insert public keys after the current point"))
+
+(define-key menu-bar-encryption-decryption-menu [export-keys]
+ '(menu-item "Export Keys" epa-export-keys
+ :help "Export public keys to a file"))
+
+(define-key menu-bar-encryption-decryption-menu [import-keys-region]
+ '(menu-item "Import Keys from Region" epa-import-keys-region
+ :help "Import public keys from the current region"))
+
+(define-key menu-bar-encryption-decryption-menu [import-keys]
+ '(menu-item "Import Keys from File" epa-import-keys
+ :help "Import public keys from a file"))
+
+(define-key menu-bar-encryption-decryption-menu [list-keys]
+ '(menu-item "List Keys" epa-list-keys
+ :help "Browse your public keyring"))
+
+(define-key menu-bar-encryption-decryption-menu [separator-keys]
+ '("--"))
+
+(define-key menu-bar-encryption-decryption-menu [encrypt-region]
+ '(menu-item "Encrypt Region" epa-encrypt-region
+ :help "Encrypt the current region"))
+
+(define-key menu-bar-encryption-decryption-menu [encrypt-file]
+ '(menu-item "Encrypt File" epa-encrypt-file
+ :help "Encrypt a file"))
+
+(define-key menu-bar-encryption-decryption-menu [sign-region]
+ '(menu-item "Sign Region" epa-sign-region
+ :help "Create digital signature of the current region"))
+
+(define-key menu-bar-encryption-decryption-menu [sign-file]
+ '(menu-item "Sign File" epa-sign-file
+ :help "Create digital signature of a file"))
+
+(define-key menu-bar-encryption-decryption-menu [verify-region]
+ '(menu-item "Verify Region" epa-verify-region
+ :help "Verify digital signature of the current region"))
+
+(define-key menu-bar-encryption-decryption-menu [verify-file]
+ '(menu-item "Verify File" epa-verify-file
+ :help "Verify digital signature of a file"))
+
+(define-key menu-bar-encryption-decryption-menu [decrypt-region]
+ '(menu-item "Decrypt Region" epa-decrypt-region
+ :help "Decrypt the current region"))
+
+(define-key menu-bar-encryption-decryption-menu [decrypt-file]
+ '(menu-item "Decrypt File" epa-decrypt-file
+ :help "Decrypt a file"))
+
(defvar menu-bar-games-menu (make-sparse-keymap "Games"))
(define-key menu-bar-tools-menu [games]