From: ueno Date: Wed, 4 Apr 2007 08:41:03 +0000 (+0000) Subject: * epa-file.el (epa-file-find-file-hook): New function. X-Git-Tag: epg-0_0_12~18 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=c6fb150af5ab9f05f34a6bc38be0dea9d9774d4c;p=elisp%2Fepg.git * epa-file.el (epa-file-find-file-hook): New function. (epa-file-enable): Add epa-file-find-file-hook to find-file-hooks. (epa-file-disable): Remove epa-file-find-file-hook from find-file-hooks. --- diff --git a/ChangeLog b/ChangeLog index 70622f0..6075199 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-04-04 Daiki Ueno + + * epa-file.el (epa-file-find-file-hook): New function. + (epa-file-enable): Add epa-file-find-file-hook to find-file-hooks. + (epa-file-disable): Remove epa-file-find-file-hook from + find-file-hooks. + 2007-03-29 Daiki Ueno * EasyPG: Version 0.0.11 released. diff --git a/epa-file.el b/epa-file.el index 599e59b..18e28be 100644 --- a/epa-file.el +++ b/epa-file.el @@ -125,8 +125,6 @@ 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)) @@ -228,6 +226,12 @@ 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))) + ;;;###autoload (defun epa-file-enable () (interactive) @@ -235,6 +239,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) (message "`epa-file' enabled"))) ;;;###autoload @@ -244,6 +249,7 @@ 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) (message "`epa-file' disabled")) (message "`epa-file' already disabled")))