[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: suggestion: reverting/notifying of files that no longer exist
From: |
Juri Linkov |
Subject: |
Re: suggestion: reverting/notifying of files that no longer exist |
Date: |
Wed, 14 Jul 2004 17:17:33 +0300 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) |
Karl Chen <address@hidden> writes:
>> One place where the warning could be added is `basic-save-buffer'.
>
> That would be good; I think it'd be even better however if it
> notified you the second you start editing. Because otherwise if
> you work on it for 20 minutes before saving, you've already
> "forked."
Notifying at the moment you start editing would be good too.
Perhaps instead of creating a new function, that could be done
in the existing function `ask-user-about-supersession-threat'
which is already used for a similar purpose, and which could be
called from `prepare_to_modify_buffer' when a previously saved
file was deleted or renamed.
Index: src/insdel.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/insdel.c,v
retrieving revision 1.178
diff -u -r1.178 insdel.c
--- src/insdel.c 22 May 2004 22:15:37 -0000 1.178
+++ src/insdel.c 14 Jul 2004 14:05:07 -0000
@@ -1931,7 +1931,14 @@
/* Make binding buffer-file-name to nil effective. */
&& !NILP (current_buffer->filename)
&& SAVE_MODIFF >= MODIFF)
- lock_file (current_buffer->file_truename);
+ {
+ lock_file (current_buffer->file_truename);
+ if (NILP (Fverify_visited_file_modtime (Fcurrent_buffer ()))
+ && current_buffer->save_length > 0
+ && NILP (Ffile_exists_p (current_buffer->filename)))
+ call1 (intern ("ask-user-about-supersession-threat"),
+ current_buffer->filename);
+ }
#else
/* At least warn if this file has changed on disk since it was visited. */
if (!NILP (current_buffer->filename)
Index: lisp/userlock.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/userlock.el,v
retrieving revision 1.14
diff -u -r1.14 userlock.el
--- lisp/userlock.el 1 Sep 2003 15:45:17 -0000 1.14
+++ lisp/userlock.el 14 Jul 2004 14:05:34 -0000
@@ -112,8 +112,10 @@
(save-window-excursion
(let (answer)
(while (null answer)
- (message "%s changed on disk; really edit the buffer? (y, n, r or C-h) "
- (file-name-nondirectory fn))
+ (message "%s %s on disk; really edit the buffer? (y, n, r or C-h) "
+ (file-name-nondirectory fn)
+ (if (file-exists-p buffer-file-name)
+ "changed" "renamed or deleted"))
(let ((tem (downcase (let ((cursor-in-echo-area t))
(read-char-exclusive)))))
(setq answer
@@ -137,8 +139,11 @@
(signal 'file-supersession
(list "File reverted" fn)))
((eq answer 'yield)
- (signal 'file-supersession
- (list "File changed on disk" fn))))))
+ (if (file-exists-p buffer-file-name)
+ (signal 'file-supersession
+ (list "File changed on disk" fn))
+ (signal 'file-supersession
+ (list "File renamed or deleted on disk" fn)))))))
(message
"File on disk now will become a backup file if you save these
changes.")
(setq buffer-backed-up nil))))
--
Juri Linkov
http://www.jurta.org/emacs/