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: Mon, 12 Jul 2004 19:18:33 +0300 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87y8lp9p2e.fsf@mail.jurta.org> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1089649315 29016 80.91.224.253 (12 Jul 2004 16:21:55 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 12 Jul 2004 16:21:55 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Jul 12 18:21:45 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 1Bk3Yn-00067j-00 for ; Mon, 12 Jul 2004 18:21:45 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Bk3Ym-000673-00 for ; Mon, 12 Jul 2004 18:21:44 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bk3b6-0003Sr-Rt for emacs-devel@quimby.gnus.org; Mon, 12 Jul 2004 12:24:08 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1Bk3b5-0003Sm-05 for emacs-devel@gnu.org; Mon, 12 Jul 2004 12:24:07 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1Bk3b2-0003SZ-AJ for emacs-devel@gnu.org; Mon, 12 Jul 2004 12:24:06 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1Bk3b2-0003SW-7p for emacs-devel@gnu.org; Mon, 12 Jul 2004 12:24:04 -0400 Original-Received: from [66.33.205.9] (helo=spatula.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Bk3Yb-0006xU-EQ for emacs-devel@gnu.org; Mon, 12 Jul 2004 12:21:33 -0400 Original-Received: from mail.jurta.org (80-235-40-58-dsl.mus.estpak.ee [80.235.40.58]) by spatula.dreamhost.com (Postfix) with ESMTP id 8D4DC17D02B; Mon, 12 Jul 2004 09:21:26 -0700 (PDT) Original-To: Karl Chen In-Reply-To: (Karl Chen's message of "Fri, 09 Jul 2004 08:47:17 -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:25621 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25621 Karl Chen 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/