epa-file: suppress file-locking question on M-x revert-buffer
authorDaiki Ueno <ueno@unixuser.org>
Mon, 13 Sep 2010 10:44:07 +0000 (19:44 +0900)
committerDaiki Ueno <ueno@unixuser.org>
Mon, 13 Sep 2010 10:44:07 +0000 (19:44 +0900)
* epa-file.el (epa-file-insert-file-contents): If visiting, bind
buffer-file-name to avoid file-locking.  (Bug#7026)

lisp/ChangeLog
lisp/epa-file.el

index dec338e..f0e59a6 100644 (file)
@@ -1,3 +1,8 @@
+2010-09-13  Daiki Ueno  <ueno@unixuser.org>
+
+       * 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  <julien@danjou.info>
 
        * notifications.el (notifications-notify): Add support for
index 24480ce..3c6cf07 100644 (file)
@@ -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