;; This program 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
+;; 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
(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
(defun epa-file-passphrase-callback-function (context key-id file)
(if (and epa-file-cache-passphrase-for-symmetric-encryption
(eq key-id 'SYM))
- (let ((entry (assoc file epa-file-passphrase-alist))
- passphrase)
- (or (copy-sequence (cdr entry))
- (progn
- (unless entry
- (setq entry (list file)
- epa-file-passphrase-alist (cons entry
- epa-file-passphrase-alist)))
- (setq passphrase (epa-passphrase-callback-function context
- key-id nil))
- (setcdr entry (copy-sequence passphrase))
- passphrase)))
+ (progn
+ (setq file (file-truename file))
+ (let ((entry (assoc file epa-file-passphrase-alist))
+ passphrase)
+ (or (copy-sequence (cdr entry))
+ (progn
+ (unless entry
+ (setq entry (list file)
+ epa-file-passphrase-alist
+ (cons entry
+ epa-file-passphrase-alist)))
+ (setq passphrase (epa-passphrase-callback-function context
+ key-id nil))
+ (setcdr entry (copy-sequence passphrase))
+ passphrase))))
(epa-passphrase-callback-function context key-id nil)))
(defun epa-file-handler (operation &rest args)
(setq file-name-handler-alist
(cons epa-file-handler file-name-handler-alist))
(add-hook 'find-file-hooks 'epa-file-find-file-hook)
+ (setq auto-mode-alist (cons epa-file-auto-mode-alist-entry auto-mode-alist))
(message "`epa-file' enabled")))
;;;###autoload
(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))
(message "`epa-file' disabled"))
(message "`epa-file' already disabled")))