]> git.eshelyaron.com Git - emacs.git/commitdiff
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 dec338e36d65379551d8d360d04ab98c7dc7124d..f0e59a6c6a663e6cd060c9d300787d196abb7ac7 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 24480ce3c76f47933af60ee6a271b2954f6fd6de..3c6cf07ea1b61acc702f2e0018ca60c4b873a852 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