From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Karl Chen Newsgroups: gmane.emacs.devel Subject: save-query-if-deleted Date: Wed, 27 Sep 2006 01:37:24 -0700 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1159346309 5537 80.91.229.2 (27 Sep 2006 08:38:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 27 Sep 2006 08:38:29 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 27 10:38:28 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GSUvh-0006V9-V7 for ged-emacs-devel@m.gmane.org; Wed, 27 Sep 2006 10:38:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GSUvh-0003tG-9Q for ged-emacs-devel@m.gmane.org; Wed, 27 Sep 2006 04:38:09 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GSUv2-0003hp-SH for emacs-devel@gnu.org; Wed, 27 Sep 2006 04:37:28 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GSUv1-0003hA-G0 for emacs-devel@gnu.org; Wed, 27 Sep 2006 04:37:27 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GSUv1-0003gy-5h for emacs-devel@gnu.org; Wed, 27 Sep 2006 04:37:27 -0400 Original-Received: from [128.32.35.215] (helo=roar.quarl.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GSUzp-0007WL-OF for emacs-devel@gnu.org; Wed, 27 Sep 2006 04:42:25 -0400 Original-Received: by roar.quarl.org (Postfix, from userid 18378) id B84005C5B2; Wed, 27 Sep 2006 01:37:24 -0700 (PDT) X-Hashcash: 1:20:060927:emacs-devel@gnu.org::/31k79dJaIzOJUfo:0000000000000000000000000000000000000000004SsP Original-To: Emacs Developement List X-Quack-Archive: 1 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: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:60267 Archived-At: I propose the patch below which adds the variable `save-query-if-deleted'. If non-nil, the `basic-save-buffer' will query before saving if the file has been deleted, but existed since last visited/saved. In this patch it defaults to nil, but I think it is a very useful feature. Usually when a file no longer exists it's because I renamed it in a shell window and forgot to re-open it in Emacs; in these situations, saving it should require confirmation. What do you think? --- files.el 22 Sep 2006 08:01:41 -0700 1.858 +++ files.el 27 Sep 2006 01:33:25 -0700 @@ -225,6 +225,11 @@ (t "[\000]")) "Regexp recognizing file names which aren't allowed by the filesystem.") +(defcustom save-query-if-deleted nil + "*Non-nil means query before saving if file has been deleted." + :type 'boolean + :group 'files) + (defcustom file-precious-flag nil "Non-nil means protect against I/O errors while saving files. Some modes set this non-nil in particular buffers. @@ -3542,10 +3547,14 @@ (error "Canceled"))) (set-visited-file-name filename))) (or (verify-visited-file-modtime (current-buffer)) - (not (file-exists-p buffer-file-name)) + (if (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))) + (if save-query-if-deleted + (yes-or-no-p (format "%s has been deleted since visited or saved. Save anew? " + (file-name-nondirectory buffer-file-name))) + t)) (error "Save not confirmed")) (save-restriction (widen) -- Karl 2006-09-27 01:32