From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: find-file-literally and save-buffer Date: Tue, 27 Mar 2007 21:19:41 -0400 Message-ID: References: <20070326115910.697F830147@Psilocybe.Update.UU.SE> <87odmfnxxw.fsf@stupidchicken.com> <87k5x3nxcl.fsf@stupidchicken.com> <20070327113711.6EE393012B@Psilocybe.Update.UU.SE> <87y7lircb4.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1175044800 26581 80.91.229.12 (28 Mar 2007 01:20:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 28 Mar 2007 01:20:00 +0000 (UTC) Cc: ams@gnu.org, emacs-devel@gnu.org To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 28 03:19:52 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HWMpL-00015Y-Pk for ged-emacs-devel@m.gmane.org; Wed, 28 Mar 2007 03:19:52 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HWMrl-0000yB-4Q for ged-emacs-devel@m.gmane.org; Tue, 27 Mar 2007 20:22:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HWMrg-0000v2-Ct for emacs-devel@gnu.org; Tue, 27 Mar 2007 21:22:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HWMre-0000sU-9t for emacs-devel@gnu.org; Tue, 27 Mar 2007 21:22:15 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HWMre-0000sK-03 for emacs-devel@gnu.org; Tue, 27 Mar 2007 20:22:14 -0500 Original-Received: from tomts36.bellnexxia.net ([209.226.175.93] helo=tomts36-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HWMpC-0003Hn-JU; Tue, 27 Mar 2007 21:19:42 -0400 Original-Received: from pastel.home ([70.55.83.113]) by tomts36-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20070328011941.ZLSO1612.tomts36-srv.bellnexxia.net@pastel.home>; Tue, 27 Mar 2007 21:19:41 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 3617F80FA; Tue, 27 Mar 2007 21:19:41 -0400 (EDT) In-Reply-To: <87y7lircb4.fsf@stupidchicken.com> (Chong Yidong's message of "Tue\, 27 Mar 2007 10\:27\:59 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.95 (gnu/linux) X-detected-kernel: Solaris 8 (1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:68691 Archived-At: >> >> | 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)