all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* save-query-if-deleted
@ 2006-09-27  8:37 Karl Chen
  2006-09-27 12:12 ` save-query-if-deleted martin rudalics
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Karl Chen @ 2006-09-27  8:37 UTC (permalink / raw)



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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-09-28  2:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-27  8:37 save-query-if-deleted Karl Chen
2006-09-27 12:12 ` save-query-if-deleted martin rudalics
2006-09-27 18:12 ` save-query-if-deleted Eli Zaretskii
2006-09-28  2:13 ` save-query-if-deleted Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.