;;; epa-file.el --- the EasyPG Assistant, transparent file encryption -*- lexical-binding: t -*-
-;; Copyright (C) 2006-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2016 Free Software Foundation, Inc.
;; Author: Daiki Ueno <ueno@unixuser.org>
;; Keywords: PGP, GnuPG
passphrase))))
(epa-passphrase-callback-function context key-id file)))
+(defvar epa-inhibit nil
+ "Non-nil means don't try to decrypt .gpg files when operating on them.")
+
;;;###autoload
(defun epa-file-handler (operation &rest args)
(save-match-data
(let ((op (get operation 'epa-file)))
- (if op
- (apply op args)
+ (if (and op (not epa-inhibit))
+ (apply op args)
(epa-file-run-real-handler operation args)))))
(defun epa-file-run-real-handler (operation args)
context
(cons #'epa-progress-callback-function
(format "Decrypting %s" file)))
- (if epa-pinentry-mode
- (setf (epg-context-pinentry-mode context) epa-pinentry-mode))
+ (setf (epg-context-pinentry-mode context) epa-pinentry-mode)
(unwind-protect
(progn
(if replace
(condition-case error
(setq string (epg-decrypt-file context local-file nil))
(error
- (epa-display-error context)
(if (setq entry (assoc file epa-file-passphrase-alist))
(setcdr entry nil))
;; If the decryption program can't be found,
(equal (cadr error) "Searching for program"))
(error "Decryption program `%s' not found"
(nth 3 error)))
- ;; Hack to prevent find-file from opening empty buffer
- ;; when decryption failed (bug#6568). See the place
- ;; where `find-file-not-found-functions' are called in
- ;; `find-file-noselect-1'.
(when (file-exists-p local-file)
+ ;; Hack to prevent find-file from opening empty buffer
+ ;; when decryption failed (bug#6568). See the place
+ ;; where `find-file-not-found-functions' are called in
+ ;; `find-file-noselect-1'.
(setq-local epa-file-error error)
(add-hook 'find-file-not-found-functions
'epa-file--find-file-not-found-function
- nil t))
+ nil t)
+ (epa-display-error context))
(signal 'file-error
(cons "Opening input file" (cdr error)))))
(set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)!
(cons #'epa-progress-callback-function
(format "Encrypting %s" file)))
(setf (epg-context-armor context) epa-armor)
- (if epa-pinentry-mode
- (setf (epg-context-pinentry-mode context) epa-pinentry-mode))
+ (setf (epg-context-pinentry-mode context) epa-pinentry-mode)
(condition-case error
(setq string
(epg-encrypt-string