diff options
Diffstat (limited to '')
| -rw-r--r-- | lisp/epa-file.el | 18 | ||||
| -rw-r--r-- | lisp/subr.el | 4 |
2 files changed, 13 insertions, 9 deletions
diff --git a/lisp/epa-file.el b/lisp/epa-file.el index ced54b6eeed..e45dbd1754e 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el | |||
| @@ -116,11 +116,15 @@ encryption is used." | |||
| 116 | (defun epa-file--find-file-not-found-function () | 116 | (defun epa-file--find-file-not-found-function () |
| 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 | ;; FIXME: How do we know that slot 3 can hold only a message related | ||
| 121 | ;; to a wrong passphrase? | ||
| 120 | (if (error-slot-value error 3) | 122 | (if (error-slot-value error 3) |
| 121 | (user-error "Wrong passphrase: %s" (error-slot-value error 3)) | 123 | (user-error "Wrong passphrase: %s" (error-slot-value error 3)) |
| 124 | ;; FIXME: Why does it make sense to add the data fields of ERROR, | ||
| 125 | ;; shifted by one position? | ||
| 122 | (signal 'file-missing | 126 | (signal 'file-missing |
| 123 | (cons "Opening input file" (error-data error)))))) | 127 | (cons "Opening input file" (cdr error)))))) |
| 124 | 128 | ||
| 125 | (defun epa--wrong-password-p (context) | 129 | (defun epa--wrong-password-p (context) |
| 126 | "Return whether a wrong password caused the error in CONTEXT." | 130 | "Return whether a wrong password caused the error in CONTEXT." |
| @@ -136,6 +140,9 @@ encryption is used." | |||
| 136 | error-string) | 140 | error-string) |
| 137 | (match-string 1 error-string)))) | 141 | (match-string 1 error-string)))) |
| 138 | 142 | ||
| 143 | (defun epa-file--error-add-context (err ctxt) | ||
| 144 | (setf (cdr error) (append (cdr error) (list ctx)))) | ||
| 145 | |||
| 139 | (defvar last-coding-system-used) | 146 | (defvar last-coding-system-used) |
| 140 | (defun epa-file-insert-file-contents (file &optional visit beg end replace) | 147 | (defun epa-file-insert-file-contents (file &optional visit beg end replace) |
| 141 | (barf-if-buffer-read-only) | 148 | (barf-if-buffer-read-only) |
| @@ -182,8 +189,7 @@ encryption is used." | |||
| 182 | ;; Don't display the *error* buffer if we just | 189 | ;; Don't display the *error* buffer if we just |
| 183 | ;; have a wrong password; let the later error | 190 | ;; have a wrong password; let the later error |
| 184 | ;; handler notify the user. | 191 | ;; handler notify the user. |
| 185 | (setf (error-data error) | 192 | (epa-file--error-add-context error wrong-password) |
| 186 | (append (error-data error) (list wrong-password))) | ||
| 187 | (epa-display-error context)) | 193 | (epa-display-error context)) |
| 188 | ;; When the .gpg file isn't an encrypted file (e.g., | 194 | ;; When the .gpg file isn't an encrypted file (e.g., |
| 189 | ;; it's a keyring.gpg file instead), then gpg will | 195 | ;; it's a keyring.gpg file instead), then gpg will |
| @@ -201,8 +207,10 @@ encryption is used." | |||
| 201 | (add-hook 'find-file-not-found-functions | 207 | (add-hook 'find-file-not-found-functions |
| 202 | #'epa-file--find-file-not-found-function | 208 | #'epa-file--find-file-not-found-function |
| 203 | nil t))) | 209 | nil t))) |
| 210 | ;; FIXME: Why does it make sense to add the data fields | ||
| 211 | ;; of ERROR, shifted by one position? | ||
| 204 | (signal (if exists 'file-error 'file-missing) | 212 | (signal (if exists 'file-error 'file-missing) |
| 205 | (cons "Opening input file" (error-data error)))))) | 213 | (cons "Opening input file" (cdr error)))))) |
| 206 | (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)! | 214 | (set-buffer buf) ;In case timer/filter changed/killed it (bug#16029)! |
| 207 | (setq-local epa-file-encrypt-to | 215 | (setq-local epa-file-encrypt-to |
| 208 | (mapcar #'car (epg-context-result-for | 216 | (mapcar #'car (epg-context-result-for |
diff --git a/lisp/subr.el b/lisp/subr.el index 3cf4e8276d6..0c2acfec335 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -586,10 +586,6 @@ Defaults to `error'." | |||
| 586 | "Return the symbol which represents the type of ERROR. | 586 | "Return the symbol which represents the type of ERROR. |
| 587 | \n(fn ERROR)") | 587 | \n(fn ERROR)") |
| 588 | 588 | ||
| 589 | (defalias 'error-data #'cdr | ||
| 590 | "Return the slots attached to ERROR, as a list. | ||
| 591 | \n(fn ERROR)") | ||
| 592 | |||
| 593 | (defun error-has-type-p (error condition) | 589 | (defun error-has-type-p (error condition) |
| 594 | "Return non-nil if ERROR is of type CONDITION (or a subtype of it)." | 590 | "Return non-nil if ERROR is of type CONDITION (or a subtype of it)." |
| 595 | (unless (error--p error) | 591 | (unless (error--p error) |