(epa--select-keys): New function.
[elisp/epg.git] / epa-file.el
index 1f939c1..599e59b 100644 (file)
   :group 'epa-file)
 
 (defcustom epa-file-cache-passphrase-for-symmetric-encryption nil
-  "If t, cache passphrase for symmetric encryption."
+  "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)
 
@@ -120,6 +125,8 @@ May either be a string or a list of strings.")
   (barf-if-buffer-read-only)
   (if (and visit (or beg end))
       (error "Attempt to visit less than an entire file"))
+  (if epa-file-inhibit-auto-save
+      (auto-save-mode 0))
   (setq file (expand-file-name file))
   (let ((local-copy (epa-file-run-real-handler #'file-local-copy (list file)))
        (context (epg-make-context))
@@ -165,8 +172,13 @@ May either be a string or a list of strings.")
   (setq file (expand-file-name file))
   (let* ((coding-system (or coding-system-for-write
                            (if (fboundp 'select-safe-coding-system)
-                               (select-safe-coding-system
-                                (point-min) (point-max))
+                               ;; This is needed since Emacs 22 has
+                               ;; no-conversion setting for *.gpg in
+                               ;; `auto-coding-alist'.
+                               (let ((buffer-file-name
+                                      (file-name-sans-extension file)))
+                                 (select-safe-coding-system
+                                  (point-min) (point-max)))
                              buffer-file-coding-system)))
         (context (epg-make-context))
         (coding-system-for-write 'binary)