From: ueno Date: Mon, 17 Apr 2006 06:19:43 +0000 (+0000) Subject: Fixed. X-Git-Tag: epgsm-branchpoint~50 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=372371d54ef4c1060f3cfc70e557b28f4a4f8ee1;p=elisp%2Fepg.git Fixed. --- diff --git a/epa-file.el b/epa-file.el index 42f04c9..b1b2681 100644 --- a/epa-file.el +++ b/epa-file.el @@ -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))) @@ -79,37 +78,39 @@ (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)