emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: find-file-literally and save-buffer


From: Stefan Monnier
Subject: Re: find-file-literally and save-buffer
Date: Tue, 27 Mar 2007 21:19:41 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (gnu/linux)

>> >> | emacs -Q
>> >> | M-x find-file-literally ~/RMAIL.empty RET
>> >> | C-u M-~   (not-modified t)
>> >> | C-x C-s   (save-buffer)
>> 
>> I think this might be related to me having my home directory under
>> version control ... I think it is because vc-arch-file-source-p
>> calls find-file-noselect, which in turn calls vc-arch-file-source-p,
>> and so on...

> Probably the fix is for vc-arch-file-source-p to check if
> get-file-buffer is nil; if so, it should perform insert-file-contents
> on a temp buffer, instead of visiting the file directly.

Sounds right,
I've just installed the patch below to address it,


        Stefan


--- vc-arch.el  29 jan 2007 13:35:19 -0500      1.23
+++ vc-arch.el  27 mar 2007 21:15:35 -0400      
@@ -109,6 +109,17 @@
 
 (defconst vc-arch-tagline-re "^\\W*arch-tag:[ \t]*\\(.*[^ \t\n]\\)")
 
+(defmacro vc-with-current-file-buffer (file &rest body)
+  (declare (indent 2) (debug t))
+  `(let ((-kill-buf- nil)
+         (-file- ,file))
+     (with-current-buffer (or (find-buffer-visiting -file-)
+                              (setq -kill-buf- (generate-new-buffer " temp")))
+       (if -kill-buf- (insert-file-contents -file-))
+       (unwind-protect
+           (progn ,@body)
+         (if -kill-buf- (kill-buffer -kill-buf-))))))
+
 (defun vc-arch-file-source-p (file)
   "Can return nil, `maybe' or a non-nil value.
 Only the value `maybe' can be trusted :-(."
@@ -122,7 +133,7 @@
          (concat ".arch-ids/" (file-name-nondirectory file) ".id")
          (file-name-directory file)))
        ;; Check the presence of a tagline.
-       (with-current-buffer (find-file-noselect file)
+       (vc-with-current-file-buffer file
          (save-excursion
            (goto-char (point-max))
            (or (re-search-backward vc-arch-tagline-re (- (point) 1000) t)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]