emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

save-query-if-deleted


From: Karl Chen
Subject: save-query-if-deleted
Date: Wed, 27 Sep 2006 01:37:24 -0700

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]