GNU bug report logs - #35497
[PATCH] Don't rewrite buffer contents after saving by rename

Previous Next

Package: emacs;

Reported by: Jonathan Tomer <jktomer <at> google.com>

Date: Mon, 29 Apr 2019 23:32:01 UTC

Severity: normal

Tags: patch

Done: Michael Albinus <michael.albinus <at> gmx.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Jonathan Tomer <jktomer <at> google.com>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 35497 <at> debbugs.gnu.org
Subject: bug#35497: [PATCH v3] Don't rewrite buffer contents after saving by rename
Date: Thu, 2 May 2019 15:04:02 -0700
[Message part 1 (text/plain, inline)]
On Thu, May 2, 2019 at 4:50 AM Michael Albinus <michael.albinus <at> gmx.de>
wrote:

> Jonathan Tomer <jktomer <at> 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.
>
> > +  "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.
>
[Message part 2 (text/html, inline)]

This bug report was last modified 6 years and 72 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.