aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/epa-file.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/epa-file.el')
-rw-r--r--lisp/epa-file.el22
1 files changed, 12 insertions, 10 deletions
diff --git a/lisp/epa-file.el b/lisp/epa-file.el
index 9bf6916ff7a..ced54b6eeed 100644
--- a/lisp/epa-file.el
+++ b/lisp/epa-file.el
@@ -117,10 +117,10 @@ encryption is used."
117 (let ((error epa-file-error)) 117 (let ((error epa-file-error))
118 (save-window-excursion 118 (save-window-excursion
119 (kill-buffer)) 119 (kill-buffer))
120 (if (nth 3 error) 120 (if (error-slot-value error 3)
121 (user-error "Wrong passphrase: %s" (nth 3 error)) 121 (user-error "Wrong passphrase: %s" (error-slot-value error 3))
122 (signal 'file-missing 122 (signal 'file-missing
123 (cons "Opening input file" (cdr error)))))) 123 (cons "Opening input file" (error-data error))))))
124 124
125(defun epa--wrong-password-p (context) 125(defun epa--wrong-password-p (context)
126 "Return whether a wrong password caused the error in CONTEXT." 126 "Return whether a wrong password caused the error in CONTEXT."
@@ -171,23 +171,25 @@ encryption is used."
171 ;; signal that as a non-file error 171 ;; signal that as a non-file error
172 ;; so that find-file-noselect-1 won't handle it. 172 ;; so that find-file-noselect-1 won't handle it.
173 ;; Borrowed from jka-compr.el. 173 ;; Borrowed from jka-compr.el.
174 (if (and (memq 'file-error (get (car error) 'error-conditions)) 174 (if (and (error-has-type-p error 'file-error)
175 (equal (cadr error) "Searching for program")) 175 (equal (error-slot-value error 1)
176 "Searching for program"))
176 (error "Decryption program `%s' not found" 177 (error "Decryption program `%s' not found"
177 (nth 3 error))) 178 (error-slot-value error 3)))
178 (let ((exists (file-exists-p local-file))) 179 (let ((exists (file-exists-p local-file)))
179 (when exists 180 (when exists
180 (if-let* ((wrong-password (epa--wrong-password-p context))) 181 (if-let* ((wrong-password (epa--wrong-password-p context)))
181 ;; Don't display the *error* buffer if we just 182 ;; Don't display the *error* buffer if we just
182 ;; have a wrong password; let the later error 183 ;; have a wrong password; let the later error
183 ;; handler notify the user. 184 ;; handler notify the user.
184 (setq error (append error (list wrong-password))) 185 (setf (error-data error)
186 (append (error-data error) (list wrong-password)))
185 (epa-display-error context)) 187 (epa-display-error context))
186 ;; When the .gpg file isn't an encrypted file (e.g., 188 ;; When the .gpg file isn't an encrypted file (e.g.,
187 ;; it's a keyring.gpg file instead), then gpg will 189 ;; it's a keyring.gpg file instead), then gpg will
188 ;; say "Unexpected exit" as the error message. In 190 ;; say "Unexpected exit" as the error message. In
189 ;; that case, just display the bytes. 191 ;; that case, just display the bytes.
190 (if (equal (caddr error) "Unexpected; Exit") 192 (if (equal (error-slot-value error 2) "Unexpected; Exit")
191 (setq string (with-temp-buffer 193 (setq string (with-temp-buffer
192 (insert-file-contents-literally local-file) 194 (insert-file-contents-literally local-file)
193 (buffer-string))) 195 (buffer-string)))
@@ -197,10 +199,10 @@ encryption is used."
197 ;; `find-file-noselect-1'. 199 ;; `find-file-noselect-1'.
198 (setq-local epa-file-error error) 200 (setq-local epa-file-error error)
199 (add-hook 'find-file-not-found-functions 201 (add-hook 'find-file-not-found-functions
200 'epa-file--find-file-not-found-function 202 #'epa-file--find-file-not-found-function
201 nil t))) 203 nil t)))
202 (signal (if exists 'file-error 'file-missing) 204 (signal (if exists 'file-error 'file-missing)
203 (cons "Opening input file" (cdr error)))))) 205 (cons "Opening input file" (error-data error))))))
204 (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)! 206 (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)!
205 (setq-local epa-file-encrypt-to 207 (setq-local epa-file-encrypt-to
206 (mapcar #'car (epg-context-result-for 208 (mapcar #'car (epg-context-result-for