Fixed.
authorueno <ueno>
Mon, 17 Apr 2006 06:19:43 +0000 (06:19 +0000)
committerueno <ueno>
Mon, 17 Apr 2006 06:19:43 +0000 (06:19 +0000)
epa-file.el

index 42f04c9..b1b2681 100644 (file)
@@ -40,8 +40,7 @@
 (defun epa-file-passphrase-callback-function (key-id buffer)
   (save-excursion
     (set-buffer buffer)
-    (if (and (eq key-id 'SYM)
-            epa-file)
+    (if (eq key-id 'SYM)
        (or epa-passphrase
            (let ((passphrase (epg-passphrase-callback-function
                               key-id buffer)))
          (setq buffer-undo-list nil)
          (make-local-variable 'epa-passphrase)
          (setq epa-passphrase passphrase)))
+    (make-local-variable 'epa-passphrase)
     (make-local-variable 'epa-file)
-    (setq epa-file (buffer-file-name))
-    (make-local-variable 'epa-passphrase)))
+    (setq epa-file (buffer-file-name))))
 
 (defun epa-write-file ()
-  (when epa-file
-    (let* ((coding-system (if (boundp 'last-coding-system-used)
-                             (condition-case nil
-                                 (write-region (point-min) (point-max) "/")
-                               (error last-coding-system-used))
-                           buffer-file-coding-system))
-          (coding-system-for-write 'binary)
-          (context (epg-make-context)))
-      (epg-context-set-passphrase-callback
-       context
-       (cons #'epa-file-passphrase-callback-function
-            (current-buffer)))
-      (write-region
-       (epg-encrypt-string
-       context
-       (encode-coding-string (buffer-string) coding-system)
-       (mapcar (lambda (key)
-                 (epg-sub-key-id (car (epg-key-sub-key-list key))))
-               (unless epa-passphrase
-                 (epa-select-keys
-                  "Select recipents for encryption.
+  (if epa-file
+      (let* ((coding-system (if (boundp 'last-coding-system-used)
+                               (condition-case nil
+                                   (write-region (point-min) (point-max) "/")
+                                 (error last-coding-system-used))
+                             buffer-file-coding-system))
+            (context (epg-make-context))
+            (coding-system-for-write 'binary))
+       (epg-context-set-passphrase-callback
+        context
+        (cons #'epa-file-passphrase-callback-function
+              (current-buffer)))
+       (write-region
+        (epg-encrypt-string
+         context
+         (encode-coding-string (buffer-string) coding-system)
+         (mapcar (lambda (key)
+                   (epg-sub-key-id (car (epg-key-sub-key-list key))))
+                 (unless epa-passphrase
+                   (epa-select-keys
+                    "Select recipents for encryption.
 If no one is selected, symmetric encryption will be performed.  "))))
-       nil (expand-file-name (buffer-file-name))))
-    (set-visited-file-modtime)
-    (set-buffer-modified-p nil)
-    t))
+        nil (expand-file-name (buffer-file-name)))
+       (if (boundp 'last-coding-system-used)
+           (setq last-coding-system-used coding-system))
+       (set-visited-file-modtime)
+       (set-buffer-modified-p nil)
+       t)))
 
 (provide 'epa-file)