summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@unixuser.org>2010-07-08 10:02:24 +0900
committerDaiki Ueno <ueno@unixuser.org>2010-07-08 10:02:24 +0900
commitc0397930d0e2a25155f6929325d8ff1966a436df (patch)
treebf34aaa9f8b531471a126aaed12722768fda0e26
parent72af86bd8cf1812d1fcc8924c4093d692040a664 (diff)
downloademacs-c0397930d0e2a25155f6929325d8ff1966a436df.tar.gz
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).
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/epa-file.el17
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 @@
+2010-07-08 Daiki Ueno <ueno@unixuser.org>
+
+ * 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).
+
2010-07-07 Agustín Martín <agustin.martin@hispalinux.es>
* 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."
(insert (epa-file--decode-coding-string string (or coding-system-for-read
'undecided)))))
+(defvar epa-file-error nil)
+(defun epa-file--find-file-not-found-function ()
+ (let ((error epa-file-error))
+ (save-window-excursion
+ (kill-buffer))
+ (signal 'file-error
+ (cons "Opening input file" (cdr error)))))
+
(defvar last-coding-system-used)
(defun epa-file-insert-file-contents (file &optional visit beg end replace)
(barf-if-buffer-read-only)
@@ -131,6 +139,15 @@ way."
(error
(if (setq entry (assoc file epa-file-passphrase-alist))
(setcdr entry nil))
+ ;; 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'.
+ (make-local-variable 'epa-file-error)
+ (setq epa-file-error error)
+ (add-hook 'find-file-not-found-functions
+ 'epa-file--find-file-not-found-function
+ nil t)
(signal 'file-error
(cons "Opening input file" (cdr error)))))
(make-local-variable 'epa-file-encrypt-to)