all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: ams@gnu.org, emacs-devel@gnu.org
Subject: Re: find-file-literally and save-buffer
Date: Tue, 27 Mar 2007 21:19:41 -0400	[thread overview]
Message-ID: <jwvps6ub2qy.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87y7lircb4.fsf@stupidchicken.com> (Chong Yidong's message of "Tue\, 27 Mar 2007 10\:27\:59 -0400")

>> >> | 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)

  parent reply	other threads:[~2007-03-28  1:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-26 11:59 find-file-literally and save-buffer Alfred M. Szmidt
2007-03-27  3:54 ` Chong Yidong
2007-03-27  4:07   ` Chong Yidong
2007-03-27  9:47     ` Alfred M. Szmidt
2007-03-27 11:37     ` Alfred M. Szmidt
2007-03-27 14:27       ` Chong Yidong
2007-03-27 18:56         ` Alfred M. Szmidt
2007-03-28  1:19         ` Stefan Monnier [this message]
2007-03-28  1:51           ` Alfred M. Szmidt
2007-03-28  2:33             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvps6ub2qy.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=ams@gnu.org \
    --cc=cyd@stupidchicken.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.