unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
Cc: emacs-devel@gnu.org
Subject: Re: suggestion: reverting/notifying of files that no longer exist
Date: Mon, 12 Jul 2004 19:18:33 +0300	[thread overview]
Message-ID: <87y8lp9p2e.fsf@mail.jurta.org> (raw)
In-Reply-To: <quack.20040709T0847.j5u0wh9o8q@hkn.eecs.berkeley.edu> (Karl Chen's message of "Fri, 09 Jul 2004 08:47:17 -0700")

Karl Chen <quarl@hkn.eecs.berkeley.edu> writes:
> I think Emacs (maybe as part of auto-revert-mode) should notify
> you when you edit files that no longer exist.  Sometimes I rename
> or move a file in shell, but still have the old file open and
> accidentally edit buffer for the old file.
>
> It would be very useful if Emacs tells you when a file that used
> to exist vanishes:
>     (1) when you edit its buffer
>     (2) if (global-)auto-revert-mode or some customizable variable
>         is enabled, as soon as the file vanishes

This is the kind of situation Emacs should warn the user about.
It's no fun having an unintentionally forked version which needs
to be merged later with the original version when the fact of forking
is discovered by the user.

One place where the warning could be added is `basic-save-buffer'.  It
could ask if the user tries to save the buffer which was at least once
saved to the file and was renamed or moved afterwards.  The complete
condition to check this situation is:

(and (not (verify-visited-file-modtime (current-buffer)))
     (not (file-exists-p buffer-file-name))
     (> buffer-saved-size 0))

It works in all cases with the exception of the case when a
0-sized file is moved or renamed.  However, this case is not
noteworthy.

Index: lisp/files.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/files.el,v
retrieving revision 1.707
diff -c -r1.707 files.el
*** lisp/files.el	26 Jun 2004 14:41:13 -0000	1.707
--- lisp/files.el	12 Jul 2004 14:05:51 -0000
***************
*** 3082,3090 ****
  		(set-visited-file-name filename)))
  	  (or (verify-visited-file-modtime (current-buffer))
! 	      (not (file-exists-p buffer-file-name))
  	      (yes-or-no-p
! 	       (format "%s has changed since visited or saved.  Save anyway? "
! 		       (file-name-nondirectory buffer-file-name)))
  	      (error "Save not confirmed"))
  	  (save-restriction
  	    (widen)
--- 3082,3093 ----
  		(set-visited-file-name filename)))
  	  (or (verify-visited-file-modtime (current-buffer))
! 	      (not (or (file-exists-p buffer-file-name)
! 		       (> buffer-saved-size 0)))
  	      (yes-or-no-p
! 	       (format "%s was %s since visited or saved.  Save anyway? "
! 		       (file-name-nondirectory buffer-file-name)
! 		       (if (file-exists-p buffer-file-name)
! 			   "changed" "renamed or deleted")))
  	      (error "Save not confirmed"))
  	  (save-restriction
  	    (widen)

-- 
Juri Linkov
http://www.jurta.org/emacs/

  reply	other threads:[~2004-07-12 16:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-09 15:47 suggestion: reverting/notifying of files that no longer exist Karl Chen
2004-07-12 16:18 ` Juri Linkov [this message]
2004-07-12 16:28   ` default file name to buffer name (was: reverting/notifying of files that no longer exist) Juri Linkov
2004-07-14  0:17     ` Richard Stallman
2004-07-12 19:00   ` suggestion: reverting/notifying of files that no longer exist Karl Chen
2004-07-14 14:17     ` Juri Linkov
2004-07-14 17:30       ` Karl Chen
2004-07-15 18:42         ` i18n (was: reverting/notifying of files that no longer exist) Juri Linkov
2004-07-14  0:16   ` suggestion: reverting/notifying of files that no longer exist Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y8lp9p2e.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).