all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Tramp file modification time for not yet existing files.
@ 2004-07-12 19:17 Luc Teirlinck
  2004-07-13  2:40 ` Luc Teirlinck
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Luc Teirlinck @ 2004-07-12 19:17 UTC (permalink / raw)
  Cc: emacs-devel

If one creates a buffer visiting a not yet existing file on a remote
machine using Tramp, then `visited-file-modtime' originally (before
the file is saved) returns 0.  The return value for local files in
the same situation is (-1 65535), that is, -1.

The problem with Tramp's return value is not just incompatibility.

If something else creates the same file, before the new buffer is
saved, then Tramp will overwrite the file that was created in the
meantime without any warning.  For local files, one gets a warning
when trying to edit for the first time after that _and_ before trying
to save the buffer. So I believe that Tramp should set the visited
file time to the standard (-1 65535).

After that we would get another problem.

           ;; If file does not exist, say it is not modified.
              (t nil)))))))

If the file does not exist and never existed, the return value needs
to be t  (unless the error is "untame"):

      /* If the file doesn't exist now and didn't exist before,
       we say that it isn't modified, provided the error is a tame
       one.  */
      if (errno == ENOENT || errno == EACCES || errno == ENOTDIR)
      st.st_mtime = -1;
      else
      st.st_mtime = 0;

If the file no longer exists, but the buffer's record believes it
still does, the return value should be nil.

Once Tramp sets the modtime to -1, it is easy to take care of all
this, except maybe for the "provided the error is a tame one" part.  I
do not know how relevant that part is, nor whether it is easy to check
from Lisp.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tramp file modification time for not yet existing files.
  2004-07-12 19:17 Tramp file modification time for not yet existing files Luc Teirlinck
@ 2004-07-13  2:40 ` Luc Teirlinck
  2004-07-18 18:59 ` Kai Grossjohann
  2004-07-24 18:48 ` Michael Albinus
  2 siblings, 0 replies; 5+ messages in thread
From: Luc Teirlinck @ 2004-07-13  2:40 UTC (permalink / raw)
  Cc: kai, emacs-devel

>From my earlier message:

   Once Tramp sets the modtime to -1, it is easy to take care of all
   this, except maybe for the "provided the error is a tame one" part.  I
   do not know how relevant that part is, nor whether it is easy to check
   from Lisp.

I meant:

Once Tramp sets the modtime to -1 for buffers visiting a not yet
existing file,...

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tramp file modification time for not yet existing files.
  2004-07-12 19:17 Tramp file modification time for not yet existing files Luc Teirlinck
  2004-07-13  2:40 ` Luc Teirlinck
@ 2004-07-18 18:59 ` Kai Grossjohann
  2004-07-18 20:12   ` Luc Teirlinck
  2004-07-24 18:48 ` Michael Albinus
  2 siblings, 1 reply; 5+ messages in thread
From: Kai Grossjohann @ 2004-07-18 18:59 UTC (permalink / raw)
  Cc: kai, emacs-devel

Luc Teirlinck <teirllm@dms.auburn.edu> writes:

> If one creates a buffer visiting a not yet existing file on a remote
> machine using Tramp, then `visited-file-modtime' originally (before
> the file is saved) returns 0.  The return value for local files in
> the same situation is (-1 65535), that is, -1.

I'm afraid that I'm just before a deadline at work at the moment, so
if you already know what needs to happen, it would be wonderful if
you could just do it.  Since the stable Tramp branch and Emacs are
now in sync, it will be easy to merge changes.

Otherwise, it might take me a couple of weekends before I have time
to look at this again.

> After that we would get another problem.
>
>            ;; If file does not exist, say it is not modified.
>               (t nil)))))))

It appears that the comment here says what should happen, but the
code does the wrong thing.  So changing the nil to t is one change
that seems to be necessary.

But I don't know what else is needed.

> If the file does not exist and never existed, the return value needs
> to be t  (unless the error is "untame"):
>
>       /* If the file doesn't exist now and didn't exist before,
>        we say that it isn't modified, provided the error is a tame
>        one.  */
>       if (errno == ENOENT || errno == EACCES || errno == ENOTDIR)
>       st.st_mtime = -1;
>       else
>       st.st_mtime = 0;
>
> If the file no longer exists, but the buffer's record believes it
> still does, the return value should be nil.
>
> Once Tramp sets the modtime to -1, it is easy to take care of all
> this, except maybe for the "provided the error is a tame one" part.  I
> do not know how relevant that part is, nor whether it is easy to check
> from Lisp.

What confuses me most is your wording of "setting the modtime".  I
think I misread it as "getting", and then I started to look for the
function visited-file-modtime, which is not a file operation...  Of
course, the misunderstanding is entirely my fault.

Do you mean that tramp-handle-set-visited-file-modtime should set the
modtime to -1 if no time has been specified and the file does not
exist?

I think Tramp now uses (0 0) for those cases.

Does Ange-FTP need a similar change?  Tramp uses (0 0) as a dont-know
value because Ange-FTP does it, and I didn't understand the issues at
that time.

Kai

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tramp file modification time for not yet existing files.
  2004-07-18 18:59 ` Kai Grossjohann
@ 2004-07-18 20:12   ` Luc Teirlinck
  0 siblings, 0 replies; 5+ messages in thread
From: Luc Teirlinck @ 2004-07-18 20:12 UTC (permalink / raw)
  Cc: kai, emacs-devel

Kai Grossjohann wrote:

   Luc Teirlinck <teirllm@dms.auburn.edu> writes:

   > If one creates a buffer visiting a not yet existing file on a remote
   > machine using Tramp, then `visited-file-modtime' originally (before
   > the file is saved) returns 0.  The return value for local files in
   > the same situation is (-1 65535), that is, -1.

   I'm afraid that I'm just before a deadline at work at the moment, so
   if you already know what needs to happen, it would be wonderful if
   you could just do it.  Since the stable Tramp branch and Emacs are
   now in sync, it will be easy to merge changes.

I will take a look at it.

   What confuses me most is your wording of "setting the modtime".

(tramp-handle-set-visited-file-modtime '(-1 65535))

   I think Tramp now uses (0 0) for those cases.

   Does Ange-FTP need a similar change?  Tramp uses (0 0) as a dont-know
   value because Ange-FTP does it, and I didn't understand the issues at
   that time.

The problem is that it makes `visited-file-modtime' return 0 and then
`verify-visited-file-modtime' will *never* warn, even though there are
situations where it should.  I will take a look at Ange-FTP.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Tramp file modification time for not yet existing files.
  2004-07-12 19:17 Tramp file modification time for not yet existing files Luc Teirlinck
  2004-07-13  2:40 ` Luc Teirlinck
  2004-07-18 18:59 ` Kai Grossjohann
@ 2004-07-24 18:48 ` Michael Albinus
  2 siblings, 0 replies; 5+ messages in thread
From: Michael Albinus @ 2004-07-24 18:48 UTC (permalink / raw)
  Cc: emacs-devel

Luc Teirlinck <teirllm@dms.auburn.edu> writes:

> If one creates a buffer visiting a not yet existing file on a remote
> machine using Tramp, then `visited-file-modtime' originally (before
> the file is saved) returns 0.  The return value for local files in
> the same situation is (-1 65535), that is, -1.

Fixed in Tramp CVS.

> Sincerely,
>
> Luc.

Best regards, Michael.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-07-24 18:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-12 19:17 Tramp file modification time for not yet existing files Luc Teirlinck
2004-07-13  2:40 ` Luc Teirlinck
2004-07-18 18:59 ` Kai Grossjohann
2004-07-18 20:12   ` Luc Teirlinck
2004-07-24 18:48 ` Michael Albinus

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.