From 91ab7f7205fc468e6c814bfd02995cfe7f80a8cb Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Mon, 13 Sep 2010 19:44:07 +0900 Subject: [PATCH] epa-file: suppress file-locking question on M-x revert-buffer * epa-file.el (epa-file-insert-file-contents): If visiting, bind buffer-file-name to avoid file-locking. (Bug#7026) --- lisp/ChangeLog | 5 +++++ lisp/epa-file.el | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 890804ae5ed..178abd0fd41 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2010-09-13 Daiki Ueno + + * epa-file.el (epa-file-insert-file-contents): If visiting, bind + buffer-file-name to avoid file-locking. (Bug#7026) + 2010-09-13 Julien Danjou * notifications.el (notifications-notify): Add support for diff --git a/lisp/epa-file.el b/lisp/epa-file.el index 24480ce3c76..3c6cf07ea1b 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -158,12 +158,17 @@ way." (if (or beg end) (setq string (substring string (or beg 0) end))) (save-excursion - (save-restriction - (narrow-to-region (point) (point)) - (epa-file-decode-and-insert string file visit beg end replace) - (setq length (- (point-max) (point-min)))) - (if replace - (delete-region (point) (point-max))) + ;; If visiting, bind off buffer-file-name so that + ;; file-locking will not ask whether we should + ;; really edit the buffer. + (let ((buffer-file-name + (if visit nil buffer-file-name))) + (save-restriction + (narrow-to-region (point) (point)) + (epa-file-decode-and-insert string file visit beg end replace) + (setq length (- (point-max) (point-min)))) + (if replace + (delete-region (point) (point-max)))) (if visit (set-visited-file-modtime)))) (if (and local-copy -- 2.11.4.GIT