emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] Save unmodified buffer when file has been deleted


From: Bastien
Subject: [PATCH] Save unmodified buffer when file has been deleted
Date: Fri, 11 Feb 2011 10:19:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

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,

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.
-- 
 Bastien

reply via email to

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