all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bastien <bastien.guerry@wikimedia.fr>
To: emacs-devel@gnu.org
Subject: [PATCH] Save unmodified buffer when file has been deleted
Date: Fri, 11 Feb 2011 10:19:08 +0100	[thread overview]
Message-ID: <87d3mz0vzn.fsf@altern.org> (raw)

[-- 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

             reply	other threads:[~2011-02-11  9:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-11  9:19 Bastien [this message]
2011-02-11  9:29 ` [PATCH] Save unmodified buffer when file has been deleted 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d3mz0vzn.fsf@altern.org \
    --to=bastien.guerry@wikimedia.fr \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.