From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.bugs Subject: bug#12507: [debbugs-tracker] Processed: severity 12507 wishlist Date: Thu, 27 Sep 2012 23:16:12 +0200 Organization: Emacs Helm Message-ID: <87obkrkvz7.fsf@gmail.com> References: <87bogubqjy.fsf@gnu.org> <873925ebpd.fsf@gnu.org> <87ipb031aj.fsf@kwarm.red-bean.com> <87sja4t48j.fsf@gmail.com> <9D98A7802F07462887BCC67BE194243B@us.oracle.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1348780624 28848 80.91.229.3 (27 Sep 2012 21:17:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Sep 2012 21:17:04 +0000 (UTC) Cc: 12507@debbugs.gnu.org To: "Drew Adams" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Sep 27 23:17:09 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1THLSE-0007ky-Jb for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Sep 2012 23:17:06 +0200 Original-Received: from localhost ([::1]:38235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THLS9-0007EI-8z for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Sep 2012 17:17:01 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THLS5-0007E1-Tj for bug-gnu-emacs@gnu.org; Thu, 27 Sep 2012 17:16:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THLS4-0000aU-M5 for bug-gnu-emacs@gnu.org; Thu, 27 Sep 2012 17:16:57 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49815) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THLS4-0000aP-GK for bug-gnu-emacs@gnu.org; Thu, 27 Sep 2012 17:16:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1THLSA-0006dp-5e for bug-gnu-emacs@gnu.org; Thu, 27 Sep 2012 17:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Thierry Volpiatto Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Sep 2012 21:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12507 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12507-submit@debbugs.gnu.org id=B12507.134878059125488 (code B ref 12507); Thu, 27 Sep 2012 21:17:02 +0000 Original-Received: (at 12507) by debbugs.gnu.org; 27 Sep 2012 21:16:31 +0000 Original-Received: from localhost ([127.0.0.1]:59361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1THLRf-0006d3-4d for submit@debbugs.gnu.org; Thu, 27 Sep 2012 17:16:31 -0400 Original-Received: from mail-we0-f172.google.com ([74.125.82.172]:59996) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1THLRc-0006cv-Qz for 12507@debbugs.gnu.org; Thu, 27 Sep 2012 17:16:29 -0400 Original-Received: by weyu46 with SMTP id u46so921708wey.3 for <12507@debbugs.gnu.org>; Thu, 27 Sep 2012 14:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:organization:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=cWI6bKmH4flCnJjMttIZF4XV563rZAIrhWiao4Oa7vM=; b=z4GifvYMk9fkVZu0Fy3oeCauNx8+HUXNP00i48P0CqIzCc/oMdDyMHz/RHJKZcxT+1 pOjHrbccq5cjpjAo+fxoxUQh1kuHnfLeRtbU7hwi8I05tRWGVyQeilXq12FEhOzqhzep BiBdT7HY9PLGYDRe6UxmGKU0IoquiwclvezLK52m6Qon0JGJBVDjPFrGgDZlEdbMhdjZ qO/ppZWGAUEfJqbnHLbscIq3N8jZebxGBM1Y1zoOH3rqiGYtaD2A7jhgb22kudWVyNAZ eq4DqGub/nM/G0EXljd96IGqfmIIKLiEZJ+gCwWNII4KDuJwWbFLiJRoNaEX0l49qJa5 LVmQ== Original-Received: by 10.216.144.92 with SMTP id m70mr2197787wej.222.1348780582202; Thu, 27 Sep 2012 14:16:22 -0700 (PDT) Original-Received: from dell-14z (lbe83-2-78-243-104-167.fbx.proxad.net. [78.243.104.167]) by mx.google.com with ESMTPS id bj3sm12809938wib.0.2012.09.27.14.16.20 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Sep 2012 14:16:21 -0700 (PDT) In-Reply-To: <9D98A7802F07462887BCC67BE194243B@us.oracle.com> (Drew Adams's message of "Thu, 27 Sep 2012 11:37:02 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:64964 Archived-At: "Drew Adams" writes: >> >> ;; Don't use write-file; we don't want this buffer to visit it. >> > >> > After write-file, the buffer is marked as visiting that file, which >> > affects the behavior of C-x C-f and a lot more (e.g. asks the user >> > for confirmation if the file was modified by some other process, ...). >> >> What about improving write-region to use backup when needed? >> Possibly writing a new write-region-something function that handle >> backup, or a write-file-noselect function. > > +1 > > And please let us know how best to accomplish that (in the doc perhaps, but also > in this thread). > > It's not clear to me how to make a backup copy of a file without visiting that > file in some buffer, however temporarily. > > For example, I can imagine this as a way to append the region to a file and back > it up: > > (write-region (point-min) (point-max) FILE 'append) > (with-current-buffer (find-file-noselect FILE) (backup-buffer)) > > But IIUC `find-file-noselect' visits the buffer (and so "asks the user for > confirmation if the file was modified by some other process"). So that's > apparently not the way to go. What is? > > Leaving the question of visiting aside for the moment, what about > `backup-buffer' here? Should it be `save-buffer' instead, so that the modes of > FILE get updated properly? Should it be just `basic-save-buffer-1' instead of > `save-buffer'? > > And should any such code take what Juri mentioned wrt vc into account? If so, > how? > > It's not clear to me how best to handle this > write-stuff-to-a-file-and-back-it-up-when-appropriate, but I (and perhaps > others) would like to learn. I haven't found the answer by looking at the > manuals or perusing the source code. Can you help? Will try to look better to this tomorrow if I find time, just for `bookmark-write-file', what about something like this? diff --git a/lisp/bookmark.el b/lisp/bookmark.el --- a/lisp/bookmark.el +++ b/lisp/bookmark.el @@ -1355,7 +1355,7 @@ (defun bookmark-write-file (file) "Write `bookmark-alist' to FILE." (bookmark-maybe-message "Saving bookmarks to file %s..." file) - (with-current-buffer (get-buffer-create " *Bookmarks*") + (with-current-buffer (find-file-noselect file) (goto-char (point-min)) (delete-region (point-min) (point-max)) (let ((print-length nil) @@ -1374,7 +1374,7 @@ ((eq 'nospecial bookmark-version-control) version-control) (t t)))) (condition-case nil - (write-region (point-min) (point-max) file) + (save-buffer) (file-error (message "Can't write %s" file))) (kill-buffer (current-buffer)) (bookmark-maybe-message -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997