unofficial mirror of emacs-devel@gnu.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

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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).