summaryrefslogtreecommitdiff
path: root/lisp/epa-file.el
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-12-05 22:40:36 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2016-12-05 22:42:09 -0800
commit38d0276ad122d1a7663ecca965506f85b4e29b7f (patch)
treefa946a61b9785fc61756ad3a4255112fd909188d /lisp/epa-file.el
parent13d4dd1add0f13c0b1462f27f9fab55a1ff67a66 (diff)
downloademacs-38d0276ad122d1a7663ecca965506f85b4e29b7f.tar.gz
emacs-38d0276ad122d1a7663ecca965506f85b4e29b7f.tar.bz2
emacs-38d0276ad122d1a7663ecca965506f85b4e29b7f.zip
Fix GPG bug introduced by Oct file-missing change
Problem with visiting nonexistent .gpg file reported by Herbert J Skuhra. * lisp/epa-file.el (epa-file--find-file-not-found-function): (epa-file-insert-file-contents, epa-file-write-region): Signal file-missing or file-error instead of epa-error.
Diffstat (limited to 'lisp/epa-file.el')
-rw-r--r--lisp/epa-file.el29
1 files changed, 15 insertions, 14 deletions
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index 2303a085909..4b0d9b3108a 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -120,7 +120,7 @@ encryption is used."
(let ((error epa-file-error))
(save-window-excursion
(kill-buffer))
- (signal (car error)
+ (signal 'file-missing
(cons "Opening input file" (cdr error)))))
(defvar last-coding-system-used)
@@ -165,18 +165,19 @@ encryption is used."
(equal (cadr error) "Searching for program"))
(error "Decryption program `%s' not found"
(nth 3 error)))
- (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)
- (epa-display-error context))
- (signal (car error)
- (cons "Opening input file" (cdr error)))))
+ (let ((exists (file-exists-p local-file)))
+ (when exists
+ ;; 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)
+ (epa-display-error context))
+ (signal (if exists 'file-error 'file-missing)
+ (cons "Opening input file" (cdr error))))))
(set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)!
(setq-local epa-file-encrypt-to
(mapcar #'car (epg-context-result-for
@@ -272,7 +273,7 @@ If no one is selected, symmetric encryption will be performed. "
(epa-display-error context)
(if (setq entry (assoc file epa-file-passphrase-alist))
(setcdr entry nil))
- (signal (car error) (cons "Opening output file" (cdr error)))))
+ (signal 'file-error (cons "Opening output file" (cdr error)))))
(epa-file-run-real-handler
#'write-region
(list string nil file append visit lockname mustbenew))