# HG changeset patch # User Daiki Ueno # Date 1278550944 -32400 # Node ID b70c159d9e1eb7277dba88030e9a30477513cc15 # Parent 750db9f3e6d8828c3a5e4775f918428256031a32 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). diff -r 750db9f3e6d8 -r b70c159d9e1e lisp/ChangeLog --- a/lisp/ChangeLog Thu Jul 08 00:18:28 2010 +0200 +++ b/lisp/ChangeLog Thu Jul 08 10:02:24 2010 +0900 @@ -1,3 +1,10 @@ +2010-07-08 Daiki Ueno + + * 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 * ispell.el (ispell-alternate-dictionary): Use file-readable-p. diff -r 750db9f3e6d8 -r b70c159d9e1e lisp/epa-file.el --- a/lisp/epa-file.el Thu Jul 08 00:18:28 2010 +0200 +++ b/lisp/epa-file.el Thu Jul 08 10:02:24 2010 +0900 @@ -101,6 +101,14 @@ (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 @@ (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)