From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: suggestion: reverting/notifying of files that no longer exist Date: Wed, 14 Jul 2004 17:17:33 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87k6x6ad1g.fsf@mail.jurta.org> References: <87y8lp9p2e.fsf@mail.jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1089815004 20085 80.91.224.253 (14 Jul 2004 14:23:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 14 Jul 2004 14:23:24 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Jul 14 16:23:06 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1Bkkf4-00067T-00 for ; Wed, 14 Jul 2004 16:23:06 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Bkkf3-0005qI-00 for ; Wed, 14 Jul 2004 16:23:05 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BkkhU-00018T-28 for emacs-devel@quimby.gnus.org; Wed, 14 Jul 2004 10:25:36 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BkkhK-00018M-3g for emacs-devel@gnu.org; Wed, 14 Jul 2004 10:25:26 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BkkhI-000189-AZ for emacs-devel@gnu.org; Wed, 14 Jul 2004 10:25:25 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BkkhI-000186-78 for emacs-devel@gnu.org; Wed, 14 Jul 2004 10:25:24 -0400 Original-Received: from [66.33.205.9] (helo=spatula.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BkkeW-0005Qm-E3 for emacs-devel@gnu.org; Wed, 14 Jul 2004 10:22:32 -0400 Original-Received: from mail.jurta.org (80-235-39-32-dsl.mus.estpak.ee [80.235.39.32]) by spatula.dreamhost.com (Postfix) with ESMTP id 6929817D028; Wed, 14 Jul 2004 07:22:28 -0700 (PDT) Original-To: Karl Chen In-Reply-To: (Karl Chen's message of "Mon, 12 Jul 2004 12:00:28 -0700") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:25685 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25685 Karl Chen 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/