unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* minor fixes for EasyPG
@ 2008-03-31  3:05 Daiki Ueno
  2008-04-01  5:30 ` Michael Olson
  0 siblings, 1 reply; 10+ messages in thread
From: Daiki Ueno @ 2008-03-31  3:05 UTC (permalink / raw)
  To: emacs-devel

Hello,

Would someone please apply the attached patch which only contains minor
bug/doc fixes for EasyPG?  Then I'll post an update of the patch:
http://article.gmane.org/gmane.emacs.devel/89452

diff --git a/doc/misc/ChangeLog b/doc/misc/ChangeLog
index 5b78839..f2c1fba 100644
--- a/doc/misc/ChangeLog
+++ b/doc/misc/ChangeLog
@@ -1,3 +1,8 @@
+2008-03-31  Daiki Ueno  <ueno@unixuser.org>
+
+	* epa.texi (Encrypting/decrypting *.gpg files): Document
+	epa-file-name-regexp.
+
 2008-03-30  Michael Albinus  <michael.albinus@gmx.de>
 
 	* dbus.texi (Synchronous Methods): New parameter TIMEOUT for
diff --git a/doc/misc/epa.texi b/doc/misc/epa.texi
index de712aa..8063690 100644
--- a/doc/misc/epa.texi
+++ b/doc/misc/epa.texi
@@ -364,6 +364,13 @@ line on the first line of the text being encrypted.
 @end lisp
 @end cartouche
 
+The file name extension of encrypted files can be controlled by
+@var{epa-file-name-regexp}.
+
+@defvar epa-file-name-regexp
+Regexp which matches filenames treated as encrypted.
+@end defvar
+
 Other variables which control the automatic encryption/decryption
 behavior are below.
 
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 806199b..7604155 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,18 @@
+2008-03-31  Daiki Ueno  <ueno@unixuser.org>
+
+	* epa.el (epa-decrypt-region): Explain the reason why this
+	function should not be used in Lisp programs.
+	(epa-decrypt-armor-in-region): Ditto.
+	(epa-verify-region): Ditto.
+	(epa-verify-cleartext-in-region): Ditto.
+	(epa-sign-region): Ditto.
+	(epa-encrypt-region): Ditto.
+
+	* epg.el (epg-start-receive-keys): Fix typo in docstring.
+
+	* epa.el (epa-select-keys): Show menu even if there is no key in
+	GnuPG's keyring.
+
 2008-03-31  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* smerge-mode.el (smerge-refine): Allow highlighting other subparts
diff --git a/lisp/epa.el b/lisp/epa.el
index 21c4e70..4f2b743 100644
--- a/lisp/epa.el
+++ b/lisp/epa.el
@@ -543,9 +543,7 @@ NAMES is a list of strings to be matched with keys.  If it is nil, all
 the keys are listed.
 If SECRET is non-nil, list secret keys instead of public keys."
   (let ((keys (epg-list-keys context names secret)))
-    (if (> (length keys) 1)
-	(epa--select-keys prompt keys)
-      keys)))
+    (epa--select-keys prompt keys)))
 
 (defun epa--show-key (key)
   (let* ((primary-sub-key (car (epg-key-sub-key-list key)))
@@ -812,7 +810,20 @@ If no one is selected, symmetric encryption will be performed.  ")))
 (defun epa-decrypt-region (start end)
   "Decrypt the current region between START and END.
 
-Don't use this command in Lisp programs!"
+Don't use this command in Lisp programs!
+Since this function operates on regions, it does some tricks such
+as coding-system detection and unibyte/multibyte conversion.  If
+you are sure how the data in the region should be treated, you
+should consider using the string based counterpart
+`epg-decrypt-string', or the file based counterpart
+`epg-decrypt-file' instead.
+
+For example:
+
+\(let ((context (epg-make-context 'OpenPGP)))
+  (decode-coding-string
+    (epg-decrypt-string context (buffer-substring start end))
+    'utf-8))"
   (interactive "r")
   (save-excursion
     (let ((context (epg-make-context epa-protocol))
@@ -859,7 +870,8 @@ Don't use this command in Lisp programs!"
 (defun epa-decrypt-armor-in-region (start end)
   "Decrypt OpenPGP armors in the current region between START and END.
 
-Don't use this command in Lisp programs!"
+Don't use this command in Lisp programs!
+See the reason described in the `epa-decrypt-region' documentation."
   (interactive "r")
   (save-excursion
     (save-restriction
@@ -885,7 +897,20 @@ Don't use this command in Lisp programs!"
 (defun epa-verify-region (start end)
   "Verify the current region between START and END.
 
-Don't use this command in Lisp programs!"
+Don't use this command in Lisp programs!
+Since this function operates on regions, it does some tricks such
+as coding-system detection and unibyte/multibyte conversion.  If
+you are sure how the data in the region should be treated, you
+should consider using the string based counterpart
+`epg-verify-string', or the file based counterpart
+`epg-verify-file' instead.
+
+For example:
+
+\(let ((context (epg-make-context 'OpenPGP)))
+  (decode-coding-string
+    (epg-verify-string context (buffer-substring start end))
+    'utf-8))"
   (interactive "r")
   (let ((context (epg-make-context epa-protocol))
 	plain)
@@ -924,7 +949,8 @@ Don't use this command in Lisp programs!"
   "Verify OpenPGP cleartext signed messages in the current region
 between START and END.
 
-Don't use this command in Lisp programs!"
+Don't use this command in Lisp programs!
+See the reason described in the `epa-verify-region' documentation."
   (interactive "r")
   (save-excursion
     (save-restriction
@@ -954,7 +980,19 @@ Don't use this command in Lisp programs!"
 (defun epa-sign-region (start end signers mode)
   "Sign the current region between START and END by SIGNERS keys selected.
 
-Don't use this command in Lisp programs!"
+Don't use this command in Lisp programs!
+Since this function operates on regions, it does some tricks such
+as coding-system detection and unibyte/multibyte conversion.  If
+you are sure how the data should be treated, you should consider
+using the string based counterpart `epg-sign-string', or the file
+based counterpart `epg-sign-file' instead.
+
+For example:
+
+\(let ((context (epg-make-context 'OpenPGP)))
+  (epg-sign-string
+    context
+    (encode-coding-string (buffer-substring start end) 'utf-8)))"
   (interactive
    (let ((verbose current-prefix-arg))
      (setq epa-last-coding-system-specified
@@ -1022,7 +1060,20 @@ Uses the `derived-mode-parent' property of the symbol to trace backwards."
 (defun epa-encrypt-region (start end recipients sign signers)
   "Encrypt the current region between START and END for RECIPIENTS.
 
-Don't use this command in Lisp programs!"
+Don't use this command in Lisp programs!
+Since this function operates on regions, it does some tricks such
+as coding-system detection and unibyte/multibyte conversion.  If
+you are sure how the data should be treated, you should consider
+using the string based counterpart `epg-encrypt-string', or the
+file based counterpart `epg-encrypt-file' instead.
+
+For example:
+
+\(let ((context (epg-make-context 'OpenPGP)))
+  (epg-encrypt-string
+    context
+    (encode-coding-string (buffer-substring start end) 'utf-8)
+    nil))"
   (interactive
    (let ((verbose current-prefix-arg)
 	 (context (epg-make-context epa-protocol))
@@ -1077,9 +1128,7 @@ If no one is selected, symmetric encryption will be performed.  ")
 
 ;;;###autoload
 (defun epa-delete-keys (keys &optional allow-secret)
-  "Delete selected KEYS.
-
-Don't use this command in Lisp programs!"
+  "Delete selected KEYS."
   (interactive
    (let ((keys (epa--marked-keys)))
      (unless keys
@@ -1094,9 +1143,7 @@ Don't use this command in Lisp programs!"
 
 ;;;###autoload
 (defun epa-import-keys (file)
-  "Import keys from FILE.
-
-Don't use this command in Lisp programs!"
+  "Import keys from FILE."
   (interactive "fFile: ")
   (setq file (expand-file-name file))
   (let ((context (epg-make-context epa-protocol)))
@@ -1115,9 +1162,7 @@ Don't use this command in Lisp programs!"
 
 ;;;###autoload
 (defun epa-import-keys-region (start end)
-  "Import keys from the region.
-
-Don't use this command in Lisp programs!"
+  "Import keys from the region."
   (interactive "r")
   (let ((context (epg-make-context epa-protocol)))
     (message "Importing...")
@@ -1134,9 +1179,7 @@ Don't use this command in Lisp programs!"
 ;;;###autoload
 (defun epa-import-armor-in-region (start end)
   "Import keys in the OpenPGP armor format in the current region
-between START and END.
-
-Don't use this command in Lisp programs!"
+between START and END."
   (interactive "r")
   (save-excursion
     (save-restriction
@@ -1156,9 +1199,7 @@ Don't use this command in Lisp programs!"
 
 ;;;###autoload
 (defun epa-export-keys (keys file)
-  "Export selected KEYS to FILE.
-
-Don't use this command in Lisp programs!"
+  "Export selected KEYS to FILE."
   (interactive
    (let ((keys (epa--marked-keys))
 	 default-name)
@@ -1185,9 +1226,7 @@ Don't use this command in Lisp programs!"
 
 ;;;###autoload
 (defun epa-insert-keys (keys)
-  "Insert selected KEYS after the point.
-
-Don't use this command in Lisp programs!"
+  "Insert selected KEYS after the point."
   (interactive
    (list (epa-select-keys (epg-make-context epa-protocol)
 			  "Select keys to export.  ")))
diff --git a/lisp/epg.el b/lisp/epg.el
index d7cd21e..e36592a 100644
--- a/lisp/epg.el
+++ b/lisp/epg.el
@@ -2411,7 +2411,7 @@ If you use this function, you will need to wait for the completion of
 `epg-gpg-program' by using `epg-wait-for-completion' and call
 `epg-reset' to clear a temporaly output file.
 If you are unsure, use synchronous version of this function
-`epg-generate-key-from-file' or `epg-generate-key-from-string' instead."
+`epg-receive-keys' instead."
   (epg-context-set-operation context 'receive-keys)
   (epg-context-set-result context nil)
   (epg--start context (cons "--recv-keys" key-id-list)))

Regards,
-- 
Daiki Ueno




^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: minor fixes for EasyPG
  2008-03-31  3:05 minor fixes for EasyPG Daiki Ueno
@ 2008-04-01  5:30 ` Michael Olson
  2008-04-18  7:49   ` update of the EasyPG integration patch (Re: " Daiki Ueno
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Olson @ 2008-04-01  5:30 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 700 bytes --]

Daiki Ueno <ueno@unixuser.org> writes:

> Hello,
>
> Would someone please apply the attached patch which only contains
> minor bug/doc fixes for EasyPG?  Then I'll post an update of the
> patch: http://article.gmane.org/gmane.emacs.devel/89452

Applied.  Remember to remove your ChangeLog entries from the patch and
include them in the email text instead.  Both entries had conflicts
which I had to manually resolve in git before pushing to CVS.

-- 
|       Michael Olson  |  FSF Associate Member #652     |
| http://mwolson.org/  |  Hobbies: Lisp, HCoop          |
| Projects: Emacs, Muse, ERC, EMMS, ErBot, DVC, Planner |
`-------------------------------------------------------'

[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* update of the EasyPG integration patch (Re: minor fixes for EasyPG
  2008-04-01  5:30 ` Michael Olson
@ 2008-04-18  7:49   ` Daiki Ueno
  2008-04-27 19:56     ` Dan Nicolaescu
                       ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Daiki Ueno @ 2008-04-18  7:49 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2122 bytes --]

>>>>> In <87r6dqywer.fsf@grepfind.mwolson.org> 
>>>>>	Michael Olson <mwolson@gnu.org> wrote:
> Daiki Ueno <ueno@unixuser.org> writes:

> > Would someone please apply the attached patch which only contains
> > minor bug/doc fixes for EasyPG?  Then I'll post an update of the
> > patch: http://article.gmane.org/gmane.emacs.devel/89452

Sorry for the delay.  Please find the patch below, which I think ready
to be installed into the trunk.

Here are responses to the comments for the previous patch:

>>>>> In <E1JR9pM-0008Cb-FD@fencepost.gnu.org> 
>>>>>	Richard Stallman <rms@gnu.org> wrote:

> All this sounds good, but it might be desirable for Auto Encryption mode
> to ask for confirmation before it decrypts any newly visited file for
> the first time.

It looks hard for me to do that, since I couldn't find an easy way to
ask before find-file, and to inhibit file-name-handler per file.

Do you have any idea?

>>>>> In <200802181951.m1IJpGsN016364@sallyv1.ics.uci.edu> 
>>>>>	Dan Nicolaescu <dann@ics.uci.edu> wrote:

>   > + (when auto-encryption-mode (auto-encryption-mode 1))
> Turning on a mode when loading a file does not seem like not a good idea.
> Instead, you could add a custom-reevaluate-setting call in startup.el

Yes, I simply dropped the above line.  Because it turned out that just
setting :init-value of define-minor-mode runs the body of
auto-encryption-mode as expected.

2008-04-18  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): Abolish.
	(epa-mode): Abolish.
	(epa-menu): Abolish.
	(epa-menu-items): Abolish.

	* epa-dired.el (epa-dired-do-decrypt): Add autoload cookie.
	(epa-dired-do-verify): Ditto.
	(epa-dired-do-sign): Ditto.
	(epa-dired-do-encrypt): Ditto.
	(epa-dired-mode): Abolish.
	(epa-global-dired-mode): Abolish.

	* 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: epg-integrate.diff --]
[-- Type: text/x-diff, Size: 12817 bytes --]

diff --git a/lisp/dired.el b/lisp/dired.el
index 375894c..521b176 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -1279,6 +1279,11 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
     (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.
 
@@ -1325,6 +1330,29 @@ Do so according to the former subdir alist OLD-SUBDIR-ALIST."
       (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
                   :help "Display image in external viewer"))
diff --git a/lisp/epa-dired.el b/lisp/epa-dired.el
index a02081b..0a72c01 100644
--- a/lisp/epa-dired.el
+++ b/lisp/epa-dired.el
@@ -26,23 +26,7 @@
 (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)
@@ -52,6 +36,7 @@
       (setq file-list (cdr file-list)))
     (revert-buffer)))
 
+;;;###autoload
 (defun epa-dired-do-verify ()
   "Verify marked files."
   (interactive)
@@ -60,6 +45,7 @@
       (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)
@@ -74,6 +60,7 @@ If no one is selected, default secret key is used.  "
       (setq file-list (cdr file-list)))
     (revert-buffer)))
 
+;;;###autoload
 (defun epa-dired-do-encrypt ()
   "Encrypt marked files."
   (interactive)
@@ -86,14 +73,6 @@ If no one is selected, symmetric encryption will be performed.  "))
       (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
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index 5580484..7d53b87 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -126,7 +126,10 @@ May either be a string or a list of strings.")
 (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)))))
 
@@ -300,7 +303,7 @@ If no one is selected, symmetric encryption will be performed.  "))))
       (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")))
 
@@ -311,30 +314,35 @@ If no one is selected, symmetric encryption will be performed.  "))))
       (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
diff --git a/lisp/epa.el b/lisp/epa.el
index 4f2b743..2e2630b 100644
--- a/lisp/epa.el
+++ b/lisp/epa.el
@@ -45,13 +45,6 @@ the separate window."
   :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"
@@ -236,44 +229,6 @@ You should bind this variable with `let', but do not set it globally.")
     (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
@@ -1257,27 +1212,6 @@ between START and END."
 ;;     (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
diff --git a/lisp/files.el b/lisp/files.el
index 07b8a06..2699946 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -1784,7 +1784,7 @@ This function ensures that none of these modifications will take place."
              (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
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 00f7678..8246e64 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -1093,6 +1093,70 @@ mail status in mode line"))
 	 (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]

[-- Attachment #3: Type: text/plain, Size: 25 bytes --]


Regards,
-- 
Daiki Ueno

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: update of the EasyPG integration patch (Re: minor fixes for EasyPG
  2008-04-18  7:49   ` update of the EasyPG integration patch (Re: " Daiki Ueno
@ 2008-04-27 19:56     ` Dan Nicolaescu
  2008-04-27 20:35     ` Glenn Morris
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Dan Nicolaescu @ 2008-04-27 19:56 UTC (permalink / raw)
  To: Daiki Ueno; +Cc: emacs-devel

Daiki Ueno <ueno@unixuser.org> writes:

  > >>>>> In <87r6dqywer.fsf@grepfind.mwolson.org> 
  > >>>>>	Michael Olson <mwolson@gnu.org> wrote:
  > > Daiki Ueno <ueno@unixuser.org> writes:
  > 
  > > > Would someone please apply the attached patch which only contains
  > > > minor bug/doc fixes for EasyPG?  Then I'll post an update of the
  > > > patch: http://article.gmane.org/gmane.emacs.devel/89452
  > 
  > Sorry for the delay.  Please find the patch below, which I think ready
  > to be installed into the trunk.

Thanks, installed.

Can you please update the NEWS entry so that it is more obvious for the
casual reader how exactly he can use this.  (maybe mention the menus for
both dired and the main menu?)





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: update of the EasyPG integration patch (Re: minor fixes for EasyPG
  2008-04-18  7:49   ` update of the EasyPG integration patch (Re: " Daiki Ueno
  2008-04-27 19:56     ` Dan Nicolaescu
@ 2008-04-27 20:35     ` Glenn Morris
  2008-04-27 23:21       ` Daiki Ueno
  2008-04-27 21:07     ` Dan Nicolaescu
  2008-04-29  8:01     ` Stefan Monnier
  3 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2008-04-27 20:35 UTC (permalink / raw)
  To: Daiki Ueno; +Cc: emacs-devel

Daiki Ueno wrote:

> --- a/lisp/epa-file.el
> +++ b/lisp/epa-file.el
> @@ -126,7 +126,10 @@ May either be a string or a list of strings.")
>  (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)))))


This is broken.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: update of the EasyPG integration patch (Re: minor fixes for EasyPG
  2008-04-18  7:49   ` update of the EasyPG integration patch (Re: " Daiki Ueno
  2008-04-27 19:56     ` Dan Nicolaescu
  2008-04-27 20:35     ` Glenn Morris
@ 2008-04-27 21:07     ` Dan Nicolaescu
  2008-04-28  1:29       ` Daiki Ueno
  2008-04-29  8:01     ` Stefan Monnier
  3 siblings, 1 reply; 10+ messages in thread
From: Dan Nicolaescu @ 2008-04-27 21:07 UTC (permalink / raw)
  To: Daiki Ueno; +Cc: emacs-devel

Daiki Ueno <ueno@unixuser.org> writes:

  > >>>>> In <87r6dqywer.fsf@grepfind.mwolson.org> 
  > >>>>>	Michael Olson <mwolson@gnu.org> wrote:
  > > Daiki Ueno <ueno@unixuser.org> writes:
  > 
  > > > Would someone please apply the attached patch which only contains
  > > > minor bug/doc fixes for EasyPG?  Then I'll post an update of the
  > > > patch: http://article.gmane.org/gmane.emacs.devel/89452
  > 
  > Sorry for the delay.  Please find the patch below, which I think ready
  > to be installed into the trunk.

Can you please also add menus to the new modes added by EasyPG?
(epa-key-list-mode surely could use one)




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: update of the EasyPG integration patch (Re: minor fixes for EasyPG
  2008-04-27 20:35     ` Glenn Morris
@ 2008-04-27 23:21       ` Daiki Ueno
  0 siblings, 0 replies; 10+ messages in thread
From: Daiki Ueno @ 2008-04-27 23:21 UTC (permalink / raw)
  To: Glenn Morris, Dan Nicolaescu; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 659 bytes --]

Glenn Morris <rgm@gnu.org> writes:

>> --- a/lisp/epa-file.el
>> +++ b/lisp/epa-file.el
>> @@ -126,7 +126,10 @@ May either be a string or a list of strings.")
>>  (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)))))
>
> This is broken.

Oops, I'm sorry.  That is a wreck of a hack which reverted before
sending the patch.

Could you please apply the following fix (diff from the current trunk)?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: epa-file.el.diff --]
[-- Type: text/x-diff, Size: 641 bytes --]

Index: lisp/epa-file.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/epa-file.el,v
retrieving revision 1.7
diff -r1.7 epa-file.el
127,135c127,132
<   ;; (save-match-data
<   ;;   (let ((op (get operation 'epa-file)))
<   ;;     (if (and op
<   ;; 	       (if (and (eq operation 'insert-file-contents)
< 			
<   ;; 			(y-or-n-p ""
<   ;; 	  (apply op args)
<   ;; 	(epa-file-run-real-handler operation args)))))
<   nil)
---
>   (save-match-data
>     (let ((op (get operation 'epa-file)))
>       (if op
>   	  (apply op args)
>   	(epa-file-run-real-handler operation args)))))
> 

[-- Attachment #3: Type: text/plain, Size: 25 bytes --]


Regards,
-- 
Daiki Ueno

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: update of the EasyPG integration patch (Re: minor fixes for EasyPG
  2008-04-27 21:07     ` Dan Nicolaescu
@ 2008-04-28  1:29       ` Daiki Ueno
  0 siblings, 0 replies; 10+ messages in thread
From: Daiki Ueno @ 2008-04-28  1:29 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 418 bytes --]

Dan Nicolaescu <dann@ics.uci.edu> writes:

> Can you please also add menus to the new modes added by EasyPG?
> (epa-key-list-mode surely could use one)

Sure, here it is.  BTW, I found a couple of typos when testing the menu.
The patch also includes a fix for them.

2008-04-28  Daiki Ueno  <ueno@unixuser.org>

	* epa.el (epa-key-list-mode-map): Add menu.
	(epa-delete-keys): Fix typo.
	(epa-import-keys): Fix typo.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: epa-key-list-menu.diff --]
[-- Type: text/x-diff, Size: 3032 bytes --]

Index: lisp/epa.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/epa.el,v
retrieving revision 1.8
diff -c -r1.8 epa.el
*** lisp/epa.el	27 Apr 2008 19:49:15 -0000	1.8
--- lisp/epa.el	28 Apr 2008 01:28:14 -0000
***************
*** 201,207 ****
  (defvar epa-last-coding-system-specified nil)
  
  (defvar epa-key-list-mode-map
!   (let ((keymap (make-sparse-keymap)))
      (define-key keymap "m" 'epa-mark-key)
      (define-key keymap "u" 'epa-unmark-key)
      (define-key keymap "d" 'epa-decrypt-file)
--- 201,208 ----
  (defvar epa-last-coding-system-specified nil)
  
  (defvar epa-key-list-mode-map
!   (let ((keymap (make-sparse-keymap))
! 	(menu-map (make-sparse-keymap)))
      (define-key keymap "m" 'epa-mark-key)
      (define-key keymap "u" 'epa-unmark-key)
      (define-key keymap "d" 'epa-decrypt-file)
***************
*** 217,222 ****
--- 218,241 ----
      (define-key keymap " " 'scroll-up)
      (define-key keymap [delete] 'scroll-down)
      (define-key keymap "q" 'epa-exit-buffer)
+     (define-key keymap [menu-bar epa-key-list-mode] (cons "Keys" menu-map))
+     (define-key menu-map [epa-key-list-delete-keys]
+       '(menu-item "Delete keys" epa-delete-keys
+ 		  :help "Delete marked keys"))
+     (define-key menu-map [epa-key-list-import-keys]
+       '(menu-item "Import keys" epa-import-keys
+ 		  :help "Import keys from a file"))
+     (define-key menu-map [epa-key-list-export-keys]
+       '(menu-item "Export keys" epa-export-keys
+ 		  :help "Export marked keys to a file"))
+     (define-key menu-map [separator-epa-key-list]
+       '(menu-item "--"))
+     (define-key menu-map [epa-key-list-unmark-key]
+       '(menu-item "Unmark key" epa-unmark-key
+ 		  :help "Unmark a key"))
+     (define-key menu-map [epa-key-list-mark-key]
+       '(menu-item "Mark key" epa-mark-key
+ 		  :help "Mark a key"))
      keymap))
  
  (defvar epa-key-mode-map
***************
*** 1094,1100 ****
      (message "Deleting...")
      (epg-delete-keys context keys allow-secret)
      (message "Deleting...done")
!     (apply #'epa-list-keys epa-list-keys-arguments)))
  
  ;;;###autoload
  (defun epa-import-keys (file)
--- 1113,1119 ----
      (message "Deleting...")
      (epg-delete-keys context keys allow-secret)
      (message "Deleting...done")
!     (apply #'epa--list-keys epa-list-keys-arguments)))
  
  ;;;###autoload
  (defun epa-import-keys (file)
***************
*** 1113,1119 ****
  	(epa-display-info (epg-import-result-to-string
  			   (epg-context-result-for context 'import))))
      (if (eq major-mode 'epa-key-list-mode)
! 	(apply #'epa-list-keys epa-list-keys-arguments))))
  
  ;;;###autoload
  (defun epa-import-keys-region (start end)
--- 1132,1138 ----
  	(epa-display-info (epg-import-result-to-string
  			   (epg-context-result-for context 'import))))
      (if (eq major-mode 'epa-key-list-mode)
! 	(apply #'epa--list-keys epa-list-keys-arguments))))
  
  ;;;###autoload
  (defun epa-import-keys-region (start end)

[-- Attachment #3: Type: text/plain, Size: 25 bytes --]


Regards,
-- 
Daiki Ueno

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: update of the EasyPG integration patch (Re: minor fixes for EasyPG
  2008-04-18  7:49   ` update of the EasyPG integration patch (Re: " Daiki Ueno
                       ` (2 preceding siblings ...)
  2008-04-27 21:07     ` Dan Nicolaescu
@ 2008-04-29  8:01     ` Stefan Monnier
  2008-04-30  5:43       ` Daiki Ueno
  3 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2008-04-29  8:01 UTC (permalink / raw)
  To: Daiki Ueno; +Cc: emacs-devel

>  ;;;###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))))
 
This sets the variable to t by default, but doesn't run the body
accordingly, so auto-encryption-mode is non-nil, but
file-name-handler-alist does not contain epa-file-handler.

Maybe you want to add a call to custom-reevaluate-setting to deal
with this problem (but it should be in a preloaded file).


        Stefan






^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: update of the EasyPG integration patch (Re: minor fixes for EasyPG
  2008-04-29  8:01     ` Stefan Monnier
@ 2008-04-30  5:43       ` Daiki Ueno
  0 siblings, 0 replies; 10+ messages in thread
From: Daiki Ueno @ 2008-04-30  5:43 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1482 bytes --]

>>>>> In <jwvskx5857q.fsf-monnier+emacs@gnu.org> 
>>>>>	Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> >  ;;;###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"

> This sets the variable to t by default, but doesn't run the body
> accordingly, so auto-encryption-mode is non-nil, but
> file-name-handler-alist does not contain epa-file-handler.

Yes.  Though I previously wrote "it turned out that just setting
:init-value of define-minor-mode runs the body of auto-encryption-mode
as expected", it was my misunderstanding.

> Maybe you want to add a call to custom-reevaluate-setting to deal
> with this problem (but it should be in a preloaded file).

Here is a patch to do this.  I've separated epa-file-hook.el, which is
preloaded, from epa-file.el.

P.S.  With this patch, I wonder why `C-h v auto-encryption-mode' shows
"Not documented as a variable."  Am I missing something?

2008-04-30  Daiki Ueno  <ueno@unixuser.org>

	* epa-file-hook.el: New file which is separated from epa-file.el.
	* loadup.el: Load "epa-file-hook".
	* startup.el (command-line): Eval the body of
	auto-encryption-mode.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: auto-encryption-mode-fix.diff --]
[-- Type: text/x-diff, Size: 9406 bytes --]

diff --git a/lisp/epa-file-hook.el b/lisp/epa-file-hook.el
new file mode 100644
index 0000000..852ad8d
--- /dev/null
+++ b/lisp/epa-file-hook.el
@@ -0,0 +1,109 @@
+;;; epa-file-hook.el --- preloaded code to enable epa-file.el
+;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
+
+;; Author: Daiki Ueno <ueno@unixuser.org>
+;; Keywords: PGP, GnuPG
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Code:
+
+(defgroup epa-file nil
+  "The EasyPG Assistant hooks for transparent file encryption"
+  :version "23.1"
+  :group 'epa)
+
+(defun epa-file--file-name-regexp-set (variable value)
+  (set-default variable value)
+  (if (fboundp 'epa-file-name-regexp-update)
+      (epa-file-name-regexp-update)))
+
+(defcustom epa-file-name-regexp "\\.gpg\\(~\\|\\.~[0-9]+~\\)?\\'"
+  "Regexp which matches filenames to be encrypted with GnuPG.
+
+If you set this outside Custom while epa-file is already enabled, you
+have to call `epa-file-name-regexp-update' after setting it to
+properly update file-name-handler-alist.  Setting this through Custom
+does that automatically."
+  :type 'regexp
+  :group 'epa-file
+  :set 'epa-file--file-name-regexp-set)
+
+(defcustom epa-file-inhibit-auto-save t
+  "If non-nil, disable auto-saving when opening an encrypted file."
+  :type 'boolean
+  :group 'epa-file)
+
+(defvar epa-file-encrypt-to nil
+  "*Recipient(s) used for encrypting files.
+May either be a string or a list of strings.")
+
+(put 'epa-file-encrypt-to 'safe-local-variable
+     (lambda (val)
+       (or (stringp val)
+	   (and (listp val)
+		(catch 'safe
+		  (mapc (lambda (elt)
+			  (unless (stringp elt)
+			    (throw 'safe nil)))
+			val)
+		  t)))))
+
+(put 'epa-file-encrypt-to 'permanent-local t)
+
+(defvar epa-file-handler
+  (cons epa-file-name-regexp 'epa-file-handler))
+
+(defvar epa-file-auto-mode-alist-entry
+  (list epa-file-name-regexp nil 'epa-file))
+
+(defun epa-file-name-regexp-update ()
+  (interactive)
+  (unless (equal (car epa-file-handler) epa-file-name-regexp)
+    (setcar epa-file-handler epa-file-name-regexp)))
+
+(defun epa-file-find-file-hook ()
+  (if (and buffer-file-name
+	   (string-match epa-file-name-regexp buffer-file-name)
+	   epa-file-inhibit-auto-save)
+      (auto-save-mode 0))
+  (set-buffer-modified-p nil))
+
+(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 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 auto-encryption-mode
+    (setq file-name-handler-alist
+	  (cons epa-file-handler file-name-handler-alist))
+    (add-hook 'find-file-hook 'epa-file-find-file-hook)
+    (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-hook)
+
+;;; epa-file-hook.el ends here
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index d7076d4..3b13469 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -24,68 +24,18 @@
 ;;; Code:
 
 (require 'epa)
-
-(defgroup epa-file nil
-  "The EasyPG Assistant hooks for transparent file encryption"
-  :version "23.1"
-  :group 'epa)
-
-(defun epa-file--file-name-regexp-set (variable value)
-  (set-default variable value)
-  (if (fboundp 'epa-file-name-regexp-update)
-      (epa-file-name-regexp-update)))
-
-(defcustom epa-file-name-regexp "\\.gpg\\(~\\|\\.~[0-9]+~\\)?\\'"
-  "Regexp which matches filenames to be encrypted with GnuPG.
-
-If you set this outside Custom while epa-file is already enabled, you
-have to call `epa-file-name-regexp-update' after setting it to
-properly update file-name-handler-alist.  Setting this through Custom
-does that automatically."
-  :type 'regexp
-  :group 'epa-file
-  :set 'epa-file--file-name-regexp-set)
+(require 'epa-file-hook)
 
 (defcustom epa-file-cache-passphrase-for-symmetric-encryption nil
   "If non-nil, cache passphrase for symmetric encryption."
   :type 'boolean
   :group 'epa-file)
 
-(defcustom epa-file-inhibit-auto-save t
-  "If non-nil, disable auto-saving when opening an encrypted file."
-  :type 'boolean
-  :group 'epa-file)
-
 (defcustom epa-file-select-keys nil
   "If non-nil, always asks user to select recipients."
   :type 'boolean
   :group 'epa-file)
 
-(defvar epa-file-encrypt-to nil
-  "*Recipient(s) used for encrypting files.
-May either be a string or a list of strings.")
-
-;;;###autoload
-(put 'epa-file-encrypt-to 'safe-local-variable
-     (lambda (val)
-       (or (stringp val)
-	   (and (listp val)
-		(catch 'safe
-		  (mapc (lambda (elt)
-			  (unless (stringp elt)
-			    (throw 'safe nil)))
-			val)
-		  t)))))
-
-;;;###autoload
-(put 'epa-file-encrypt-to 'permanent-local t)
-
-(defvar epa-file-handler
-  (cons epa-file-name-regexp 'epa-file-handler))
-
-(defvar epa-file-auto-mode-alist-entry
-  (list epa-file-name-regexp nil 'epa-file))
-
 (defvar epa-file-passphrase-alist nil)
 
 (eval-and-compile
@@ -98,11 +48,6 @@ May either be a string or a list of strings.")
       (defalias 'epa-file--decode-coding-string 'decode-coding-string)
     (defalias 'epa-file--decode-coding-string 'identity)))
 
-(defun epa-file-name-regexp-update ()
-  (interactive)
-  (unless (equal (car epa-file-handler) epa-file-name-regexp)
-    (setcar epa-file-handler epa-file-name-regexp)))
-
 (defun epa-file-passphrase-callback-function (context key-id file)
   (if (and epa-file-cache-passphrase-for-symmetric-encryption
 	   (eq key-id 'SYM))
@@ -123,6 +68,7 @@ May either be a string or a list of strings.")
 		passphrase))))
     (epa-passphrase-callback-function context key-id nil)))
 
+;;;###autoload
 (defun epa-file-handler (operation &rest args)
   (save-match-data
     (let ((op (get operation 'epa-file)))
@@ -273,13 +219,6 @@ If no one is selected, symmetric encryption will be performed.  "
 	(message "Wrote %s" buffer-file-name))))
 (put 'write-region 'epa-file 'epa-file-write-region)
 
-(defun epa-file-find-file-hook ()
-  (if (and buffer-file-name
-	   (string-match epa-file-name-regexp buffer-file-name)
-	   epa-file-inhibit-auto-save)
-      (auto-save-mode 0))
-  (set-buffer-modified-p nil))
-
 (defun epa-file-select-keys ()
   "Select recipients for encryption."
   (interactive)
@@ -317,29 +256,6 @@ If no one is selected, symmetric encryption will be performed.  "))))
 	(message "`epa-file' disabled"))
     (message "`epa-file' already disabled")))
 
-;;;###autoload
-(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 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 auto-encryption-mode
-    (setq file-name-handler-alist
-	  (cons epa-file-handler file-name-handler-alist))
-    (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
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 1bf413b..153b53f 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -95,6 +95,7 @@
 (load "help")
 
 (load "jka-cmpr-hook")
+(load "epa-file-hook")
 ;; Any Emacs Lisp source file (*.el) loaded here after can contain
 ;; multilingual text.
 (load "international/mule-cmds")
diff --git a/lisp/startup.el b/lisp/startup.el
index f5ce1b7..a4f5c6b 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -847,6 +847,7 @@ opening the first frame (e.g. open a connection to an X server).")
   (custom-reevaluate-setting 'focus-follows-mouse)
   (custom-reevaluate-setting 'global-auto-composition-mode)
   (custom-reevaluate-setting 'transient-mark-mode)
+  (custom-reevaluate-setting 'auto-encryption-mode)
 
   (normal-erase-is-backspace-setup-frame)
 

[-- Attachment #3: Type: text/plain, Size: 25 bytes --]


Regards,
-- 
Daiki Ueno

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-04-30  5:43 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-31  3:05 minor fixes for EasyPG Daiki Ueno
2008-04-01  5:30 ` Michael Olson
2008-04-18  7:49   ` update of the EasyPG integration patch (Re: " Daiki Ueno
2008-04-27 19:56     ` Dan Nicolaescu
2008-04-27 20:35     ` Glenn Morris
2008-04-27 23:21       ` Daiki Ueno
2008-04-27 21:07     ` Dan Nicolaescu
2008-04-28  1:29       ` Daiki Ueno
2008-04-29  8:01     ` Stefan Monnier
2008-04-30  5:43       ` Daiki Ueno

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).