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: Fri, 28 Sep 2012 11:04:34 +0200 Organization: Emacs Helm Message-ID: <87haqildr1.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 1348823115 8197 80.91.229.3 (28 Sep 2012 09:05:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 28 Sep 2012 09:05:15 +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 Fri Sep 28 11:05:19 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 1THWVT-0005NC-P9 for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Sep 2012 11:05:11 +0200 Original-Received: from localhost ([::1]:53801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THWVO-0003Pt-81 for geb-bug-gnu-emacs@m.gmane.org; Fri, 28 Sep 2012 05:05:06 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THWVE-0003Hc-W7 for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2012 05:05:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THWVD-0006F5-6O for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2012 05:04:56 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THWVD-0006F1-2f for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2012 05:04:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1THWVK-0007sx-WD for bug-gnu-emacs@gnu.org; Fri, 28 Sep 2012 05:05:03 -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: Fri, 28 Sep 2012 09:05: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.134882309730298 (code B ref 12507); Fri, 28 Sep 2012 09:05:02 +0000 Original-Received: (at 12507) by debbugs.gnu.org; 28 Sep 2012 09:04:57 +0000 Original-Received: from localhost ([127.0.0.1]:59778 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1THWVE-0007sb-87 for submit@debbugs.gnu.org; Fri, 28 Sep 2012 05:04:56 -0400 Original-Received: from mail-we0-f172.google.com ([74.125.82.172]:39261) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1THWVA-0007sQ-7M for 12507@debbugs.gnu.org; Fri, 28 Sep 2012 05:04:53 -0400 Original-Received: by weyu46 with SMTP id u46so1234524wey.3 for <12507@debbugs.gnu.org>; Fri, 28 Sep 2012 02:04:42 -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=MRv9XGg3T4YxCEXr7Ldk/YJdof84QR+rLw4ipWJJBFI=; b=F05yos5iTMMnWLioV3ZtzMLWgABVIIUU6iynwez0EZ1ZklKNc/j8z1Qwsws8527NYB s0IVURAqejZz50KrqYidnlzziyoCzf5E0cSaTKjn+HKrdubc7xRKS3ADnht4qjxVyl2I 6WAbjeSo7u5letYraLsTwYxUBR1ZrMZVxkoeXrcDctVk80hI+oVresGg/8wkQAExdjt9 TdGIFtNYXHWAEHvn9p/Es8PuRm1glkJCWdR7q+J6eqMaEtU4MqgwZcfHnxJxTsKysqct mXGwPqz45I39P3riYYErv1mS9JaQkbAU2GPsEINQqy/1xOhore+Eyvx7fnYyqb2zUTog DPxQ== Original-Received: by 10.180.80.134 with SMTP id r6mr2474145wix.1.1348823082507; Fri, 28 Sep 2012 02:04:42 -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 fb20sm18182102wid.1.2012.09.28.02.04.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 28 Sep 2012 02:04:41 -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:64974 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)) This is not efficient IMO, like the actual version of `bookmark-write-file': 1) create a new buffer named "*Bookmarks*". 2) erase buffer 3) write data to it. 4) write contents of this buffer to FILE. 5) save this FILE. instead: 1) open FILE buffer 2) erase buffer 3) write data to it 4) save 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? What is the problem for this? What if you open another emacs session, bookmark something in this session, (don't save and don't quit session) switch to the initial session, bookmark something there and save bookmarks? It is good if it ask you for confirmation at some point, no? > 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'? `save-buffer' do all the job (saving and backing up), so why writing to buffer and then using `backup-buffer' > And should any such code take what Juri mentioned wrt vc into account? If so, > how? `save-buffer' handle that. > 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? I think that doing like in the patch I sent is not too bad: (with-current-buffer (find-file-noselect file) write--data--here [...] (save-buffer)) No more is needed I think, but maybe I miss something? Also, the use of `bookmark-version-control' is questionable, why handling this file specially? If following that, we should have a special variable for .emacs-custom.el, desktop, history, etc... which is non--sense. If this variable is removed, the global value of version-control will be used and .emacs.bmk will be backed up like any other file, like it does (or should do because it is broken with write-region) with its default value 'nospecial. Note that with the patch I sent, it seems a little bit faster to save, but maybe I am wrong, need to verify. (we write one time the data and save instead of writing two time and save) -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997