emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tramp file modification time for not yet existing files.


From: Luc Teirlinck
Subject: Tramp file modification time for not yet existing files.
Date: Mon, 12 Jul 2004 14:17:22 -0500 (CDT)

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]