diff options
| author | Daiki Ueno | 2010-07-08 10:02:24 +0900 |
|---|---|---|
| committer | Daiki Ueno | 2010-07-08 10:02:24 +0900 |
| commit | c0397930d0e2a25155f6929325d8ff1966a436df (patch) | |
| tree | bf34aaa9f8b531471a126aaed12722768fda0e26 /lisp | |
| parent | 72af86bd8cf1812d1fcc8924c4093d692040a664 (diff) | |
| download | emacs-c0397930d0e2a25155f6929325d8ff1966a436df.tar.gz emacs-c0397930d0e2a25155f6929325d8ff1966a436df.zip | |
Prevent find-file from opening empty buffer when decryptin failed (bug#6568).
* epa-file.el (epa-file-error, epa-file--find-file-not-found-function)
(epa-file-insert-file-contents): Hack to prevent
find-file from opening empty buffer when decryptin failed
(bug#6568).
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/epa-file.el | 17 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6fef9173109..f793f91a932 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2010-07-08 Daiki Ueno <ueno@unixuser.org> | ||
| 2 | |||
| 3 | * epa-file.el (epa-file-error, epa-file--find-file-not-found-function) | ||
| 4 | (epa-file-insert-file-contents): Hack to prevent | ||
| 5 | find-file from opening empty buffer when decryptin failed | ||
| 6 | (bug#6568). | ||
| 7 | |||
| 1 | 2010-07-07 Agustín Martín <agustin.martin@hispalinux.es> | 8 | 2010-07-07 Agustín Martín <agustin.martin@hispalinux.es> |
| 2 | 9 | ||
| 3 | * ispell.el (ispell-alternate-dictionary): Use file-readable-p. | 10 | * ispell.el (ispell-alternate-dictionary): Use file-readable-p. |
diff --git a/lisp/epa-file.el b/lisp/epa-file.el index 2bbb0aa6455..5870f23bf13 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el | |||
| @@ -101,6 +101,14 @@ way." | |||
| 101 | (insert (epa-file--decode-coding-string string (or coding-system-for-read | 101 | (insert (epa-file--decode-coding-string string (or coding-system-for-read |
| 102 | 'undecided))))) | 102 | 'undecided))))) |
| 103 | 103 | ||
| 104 | (defvar epa-file-error nil) | ||
| 105 | (defun epa-file--find-file-not-found-function () | ||
| 106 | (let ((error epa-file-error)) | ||
| 107 | (save-window-excursion | ||
| 108 | (kill-buffer)) | ||
| 109 | (signal 'file-error | ||
| 110 | (cons "Opening input file" (cdr error))))) | ||
| 111 | |||
| 104 | (defvar last-coding-system-used) | 112 | (defvar last-coding-system-used) |
| 105 | (defun epa-file-insert-file-contents (file &optional visit beg end replace) | 113 | (defun epa-file-insert-file-contents (file &optional visit beg end replace) |
| 106 | (barf-if-buffer-read-only) | 114 | (barf-if-buffer-read-only) |
| @@ -131,6 +139,15 @@ way." | |||
| 131 | (error | 139 | (error |
| 132 | (if (setq entry (assoc file epa-file-passphrase-alist)) | 140 | (if (setq entry (assoc file epa-file-passphrase-alist)) |
| 133 | (setcdr entry nil)) | 141 | (setcdr entry nil)) |
| 142 | ;; Hack to prevent find-file from opening empty buffer | ||
| 143 | ;; when decryption failed (bug#6568). See the place | ||
| 144 | ;; where `find-file-not-found-functions' are called in | ||
| 145 | ;; `find-file-noselect-1'. | ||
| 146 | (make-local-variable 'epa-file-error) | ||
| 147 | (setq epa-file-error error) | ||
| 148 | (add-hook 'find-file-not-found-functions | ||
| 149 | 'epa-file--find-file-not-found-function | ||
| 150 | nil t) | ||
| 134 | (signal 'file-error | 151 | (signal 'file-error |
| 135 | (cons "Opening input file" (cdr error))))) | 152 | (cons "Opening input file" (cdr error))))) |
| 136 | (make-local-variable 'epa-file-encrypt-to) | 153 | (make-local-variable 'epa-file-encrypt-to) |