all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Save unmodified buffer when file has been deleted
@ 2011-02-11  9:19 Bastien
  2011-02-11  9:29 ` Eli Zaretskii
  2011-02-11 14:38 ` Stefan Monnier
  0 siblings, 2 replies; 12+ messages in thread
From: Bastien @ 2011-02-11  9:19 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

If you accidently delete the file while an unmodified buffer is visiting
it, trying to save this buffer will fail because it's unmodified.

This patch fixes this problem.

Let me know if it's okay to commit it (with a proper ChangeLog entry).

Thanks,


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: basic_save_buffer.patch --]
[-- Type: text/x-patch, Size: 670 bytes --]

diff --git a/lisp/files.el b/lisp/files.el
index 8b42eaa..029c55d 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4309,7 +4309,11 @@ Before and after saving the buffer, this function runs
     ;; In an indirect buffer, save its base buffer instead.
     (if (buffer-base-buffer)
 	(set-buffer (buffer-base-buffer)))
-    (if (buffer-modified-p)
+    (if (or (buffer-modified-p)
+	    ;; handle the case when no modification has been made but
+	    ;; the file has been delete
+	    (and (buffer-file-name)
+		 (not (file-exists-p (buffer-file-name)))))
 	(let ((recent-save (recent-auto-save-p))
 	      setmodes)
 	  ;; If buffer has no file name, ask user for one.

[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

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

end of thread, other threads:[~2011-02-11 23:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-11  9:19 [PATCH] Save unmodified buffer when file has been deleted Bastien
2011-02-11  9:29 ` Eli Zaretskii
2011-02-11  9:48   ` Bastien
2011-02-11 15:13     ` Eli Zaretskii
2011-02-11 17:56       ` Bastien
2011-02-11 18:50         ` Eli Zaretskii
2011-02-11 19:01           ` Bastien
2011-02-11 19:29             ` Eli Zaretskii
2011-02-11 14:38 ` Stefan Monnier
2011-02-11 14:55   ` Lennart Borgman
2011-02-11 23:02     ` Stefan Monnier
2011-02-11 17:37   ` Bastien

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.