diff options
| author | Paul Eggert | 2016-12-05 22:40:36 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-12-05 22:42:09 -0800 |
| commit | 38d0276ad122d1a7663ecca965506f85b4e29b7f (patch) | |
| tree | fa946a61b9785fc61756ad3a4255112fd909188d | |
| parent | 13d4dd1add0f13c0b1462f27f9fab55a1ff67a66 (diff) | |
| download | emacs-38d0276ad122d1a7663ecca965506f85b4e29b7f.tar.gz 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.
| -rw-r--r-- | lisp/epa-file.el | 29 |
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." | |||
| 120 | (let ((error epa-file-error)) | 120 | (let ((error epa-file-error)) |
| 121 | (save-window-excursion | 121 | (save-window-excursion |
| 122 | (kill-buffer)) | 122 | (kill-buffer)) |
| 123 | (signal (car error) | 123 | (signal 'file-missing |
| 124 | (cons "Opening input file" (cdr error))))) | 124 | (cons "Opening input file" (cdr error))))) |
| 125 | 125 | ||
| 126 | (defvar last-coding-system-used) | 126 | (defvar last-coding-system-used) |
| @@ -165,18 +165,19 @@ encryption is used." | |||
| 165 | (equal (cadr error) "Searching for program")) | 165 | (equal (cadr error) "Searching for program")) |
| 166 | (error "Decryption program `%s' not found" | 166 | (error "Decryption program `%s' not found" |
| 167 | (nth 3 error))) | 167 | (nth 3 error))) |
| 168 | (when (file-exists-p local-file) | 168 | (let ((exists (file-exists-p local-file))) |
| 169 | ;; Hack to prevent find-file from opening empty buffer | 169 | (when exists |
| 170 | ;; when decryption failed (bug#6568). See the place | 170 | ;; Hack to prevent find-file from opening empty buffer |
| 171 | ;; where `find-file-not-found-functions' are called in | 171 | ;; when decryption failed (bug#6568). See the place |
| 172 | ;; `find-file-noselect-1'. | 172 | ;; where `find-file-not-found-functions' are called in |
| 173 | (setq-local epa-file-error error) | 173 | ;; `find-file-noselect-1'. |
| 174 | (add-hook 'find-file-not-found-functions | 174 | (setq-local epa-file-error error) |
| 175 | 'epa-file--find-file-not-found-function | 175 | (add-hook 'find-file-not-found-functions |
| 176 | nil t) | 176 | 'epa-file--find-file-not-found-function |
| 177 | (epa-display-error context)) | 177 | nil t) |
| 178 | (signal (car error) | 178 | (epa-display-error context)) |
| 179 | (cons "Opening input file" (cdr error))))) | 179 | (signal (if exists 'file-error 'file-missing) |
| 180 | (cons "Opening input file" (cdr error)))))) | ||
| 180 | (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)! | 181 | (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)! |
| 181 | (setq-local epa-file-encrypt-to | 182 | (setq-local epa-file-encrypt-to |
| 182 | (mapcar #'car (epg-context-result-for | 183 | (mapcar #'car (epg-context-result-for |
| @@ -272,7 +273,7 @@ If no one is selected, symmetric encryption will be performed. " | |||
| 272 | (epa-display-error context) | 273 | (epa-display-error context) |
| 273 | (if (setq entry (assoc file epa-file-passphrase-alist)) | 274 | (if (setq entry (assoc file epa-file-passphrase-alist)) |
| 274 | (setcdr entry nil)) | 275 | (setcdr entry nil)) |
| 275 | (signal (car error) (cons "Opening output file" (cdr error))))) | 276 | (signal 'file-error (cons "Opening output file" (cdr error))))) |
| 276 | (epa-file-run-real-handler | 277 | (epa-file-run-real-handler |
| 277 | #'write-region | 278 | #'write-region |
| 278 | (list string nil file append visit lockname mustbenew)) | 279 | (list string nil file append visit lockname mustbenew)) |