From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Jonathan Tomer Newsgroups: gmane.emacs.bugs Subject: bug#35497: [PATCH v3] Don't rewrite buffer contents after saving by rename Date: Thu, 2 May 2019 15:04:02 -0700 Message-ID: References: <83tveeosqe.fsf@gnu.org> <20190501230200.46879-1-jktomer@google.com> <87ftpx5b33.fsf@gmx.de> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000770e350587eed0ff" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="211685"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 35497@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 03 00:05:17 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hMJpM-000ss0-4p for geb-bug-gnu-emacs@m.gmane.org; Fri, 03 May 2019 00:05:16 +0200 Original-Received: from localhost ([127.0.0.1]:59117 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMJpL-0007ED-70 for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 May 2019 18:05:15 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hMJpA-0007Cw-Ux for bug-gnu-emacs@gnu.org; Thu, 02 May 2019 18:05:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hMJp8-00076r-T0 for bug-gnu-emacs@gnu.org; Thu, 02 May 2019 18:05:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33657) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hMJp8-00076e-LT for bug-gnu-emacs@gnu.org; Thu, 02 May 2019 18:05:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hMJp8-0001Ti-F0 for bug-gnu-emacs@gnu.org; Thu, 02 May 2019 18:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jonathan Tomer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 May 2019 22:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 35497 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 35497-submit@debbugs.gnu.org id=B35497.15568346625630 (code B ref 35497); Thu, 02 May 2019 22:05:02 +0000 Original-Received: (at 35497) by debbugs.gnu.org; 2 May 2019 22:04:22 +0000 Original-Received: from localhost ([127.0.0.1]:47201 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hMJoT-0001Sk-Ld for submit@debbugs.gnu.org; Thu, 02 May 2019 18:04:22 -0400 Original-Received: from mail-vs1-f68.google.com ([209.85.217.68]:41254) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hMJoR-0001SW-4O for 35497@debbugs.gnu.org; Thu, 02 May 2019 18:04:19 -0400 Original-Received: by mail-vs1-f68.google.com with SMTP id g187so2355540vsc.8 for <35497@debbugs.gnu.org>; Thu, 02 May 2019 15:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ggXtjxw76o4SQzo3dIsSi0iNkUtrbNlQkIPkuc3gwTA=; b=i5PMz2UoL7fyWOsrOG3qk04NoR3fj/ABB1/2OWRUA4lxYv7eM13GLrD9ZvAo1getIx vJtMmWMQxHmwgMZ1OOws3k815/z1RNcpfFfSg4eiLiZawlrqfk1anPlDSdvToJj/R/La QpTykVlXiOxBVsIiyDJ8xo/r1+/ssq1djCG+sPgH6hJz9UUyMhphbIB6KkoKDl0GcMDJ TSUiv53xDhbHh7sCJlZ/3tCMF7NBa/ib5buOnT2j772bhcGFTPiGC2hLhjqrNqvwhtJI hlKZoUlDpJBZVP11RtmKZC6hZlIzaxun7GeJUvsNEaDkAEOHmXb++VFD0K2Ub8n342lx A1NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ggXtjxw76o4SQzo3dIsSi0iNkUtrbNlQkIPkuc3gwTA=; b=ITilGs+HM4kz9ns7f+zdzsWw5yFC283DWWera7s1sSeHFDHoDzsNjo/GnYu8rjilS+ R0FAa7J+4ymqjC4UM/mGy7d7+aZU5jcqvl7pkdUjPF84W3blw/blkZ/HfSQggY/GKiyl JAQTYDwnhbmhHBu8Ue0jaZgn6VB2E/8PouNOam0fsIFszjZQYrqnxUdopuSFVjCY309M p9ERf+jUcBFiZRVaqhm/mHTeN7JlaSPoRzMS6bvqGztYqtgRqt25gCbni2Rzlmj6N93v Xu45tR+BzmnLXpdLE6gvLq81ptY3qC8EXq6oTXGOLS9jv/+qvnm3ti+H5UqNNU3Igp7X H8Yg== X-Gm-Message-State: APjAAAUOEZ5lF5Y5N+V/CitxPRJ5XV9ysafaeSpMQoXNm0NIcPv32rnC eHNDwGHDDd3L2dAD19lfm6Dbq/aqs87D2TN/iGpnoA== X-Google-Smtp-Source: APXvYqw0wVnTxw393ilrX52ehib8Tb+z2yiRzwRYU8312kZRdxKX3cQoIREPiEp2MsS25n/Z63RuDpJTMzJbkrNmmEk= X-Received: by 2002:a67:7bd2:: with SMTP id w201mr3766101vsc.120.1556834652958; Thu, 02 May 2019 15:04:12 -0700 (PDT) In-Reply-To: <87ftpx5b33.fsf@gmx.de> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.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" Xref: news.gmane.org gmane.emacs.bugs:158670 Archived-At: --000000000000770e350587eed0ff Content-Type: text/plain; charset="UTF-8" On Thu, May 2, 2019 at 4:50 AM Michael Albinus wrote: > Jonathan Tomer writes: > > Hi Jonathan, > > > +(ert-deftest tramp-test46-file-precious-flag () > > Since this belongs rather to write-region, I would call it > `tramp-test10-write-region-file-precious-flag', and move it to the > repsective place in file. > > > + "Check that file-precious-flag is respected with Tramp in use." > > + (let* ((temp-file (make-temp-file "emacs")) > > + (remote-file (concat "/mock:localhost:" temp-file)) > > Please don't do this. The mock method does not work everywhere, for > example on an MS Windows machine. > > `file-precious-flag' is handled in the tramp-sh.el handler only. So you > might start with the test `tramp--test-sh-p', and skip otherwise. > > And then you could use the same mechanism like in the other > tests. Something like this: > > --8<---------------cut here---------------start------------->8--- > (ert-deftest tramp-test10-write-region-file-precious-flag () > "Check that `file-precious-flag' is respected with Tramp in use." > (skip-unless (tramp--test-enabled)) > (skip-unless (tramp--test-sh-p)) > > (let ((tmp-name (tramp--test-make-temp-name)) > (advice (lambda (_start _end filename &rest r) > (should-not (string= filename tmp-name))))) > > (unwind-protect > (with-current-buffer (find-file-noselect tmp-name) > ;; Write initial contents. Adapt `visited-file-modtime' > ;; in order to suppress confirmation. > (insert "foo") > (write-region nil nil tmp-name) > (set-visited-file-modtime) > ;; Run the test. > (advice-add 'write-region :before advice) > (setq-local file-precious-flag t) > (insert "bar") > (should (null (save-buffer)))) > > ;; Cleanup. > (ignore-errors (advice-remove 'write-region advice)) > (ignore-errors (delete-file tmp-name))))) > --8<---------------cut here---------------end--------------->8--- > > I haven't tested further, this gives an error for me. Don't know yet, > whether it is the test definition, or (more likely) a problem in Tramp. > Changing let to let* fixes the test. New patch incoming. > > Best regards, Michael. > --000000000000770e350587eed0ff Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, May 2, 2019 at 4:50 AM Michael Al= binus <michael.albinus@gmx.de> wrote:
Jonathan To= mer <jktomer@google.com> writes:

Hi Jonathan,

> +(ert-deftest tramp-test46-file-precious-flag ()

Since this belongs rather to write-region, I would call it
`tramp-test10-write-region-file-precious-flag', and move it to the
repsective place in file.

> +=C2=A0 "Check that file-precious-flag is respected with Tramp in= use."
> +=C2=A0 (let* ((temp-file (make-temp-file "emacs"))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(remote-file (concat "/mock:lo= calhost:" temp-file))

Please don't do this. The mock method does not work everywhere, for
example on an MS Windows machine.

`file-precious-flag' is handled in the tramp-sh.el handler only. So you=
might start with the test `tramp--test-sh-p', and skip otherwise.

And then you could use the same mechanism like in the other
tests. Something like this:

--8<---------------cut here---------------start------------->8---
(ert-deftest tramp-test10-write-region-file-precious-flag ()
=C2=A0 "Check that `file-precious-flag' is respected with Tramp in= use."
=C2=A0 (skip-unless (tramp--test-enabled))
=C2=A0 (skip-unless (tramp--test-sh-p))

=C2=A0 (let ((tmp-name (tramp--test-make-temp-name))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (advice (lambda (_start _end filename &rest= r)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (should-not = (string=3D filename tmp-name)))))

=C2=A0 =C2=A0 (unwind-protect
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (with-current-buffer (find-file-noselect tmp-na= me)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; Write initial contents.=C2=A0 Adapt `= visited-file-modtime'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; in order to suppress confirmation. =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert "foo")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (write-region nil nil tmp-name)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (set-visited-file-modtime)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; Run the test.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (advice-add 'write-region :before ad= vice)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (setq-local file-precious-flag t)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert "bar")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (should (null (save-buffer))))

=C2=A0 =C2=A0 =C2=A0 ;; Cleanup.
=C2=A0 =C2=A0 =C2=A0 (ignore-errors (advice-remove 'write-region advice= ))
=C2=A0 =C2=A0 =C2=A0 (ignore-errors (delete-file tmp-name)))))
--8<---------------cut here---------------end--------------->8---

I haven't tested further, this gives an error for me. Don't know ye= t,
whether it is the test definition, or (more likely) a problem in Tramp.
=

Changing let to let* fixes the test. New p= atch incoming.
=C2=A0

Best regards, Michael.
--000000000000770e350587eed0ff--