bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#25642: 26.0.50; Save unmodified buffers not visiting a file yet


From: Tino Calancha
Subject: bug#25642: 26.0.50; Save unmodified buffers not visiting a file yet
Date: Tue, 07 Feb 2017 23:08:42 +0900

emacs -Q
C-x b foo
foo ; Insert something.
M-: (set-buffer-modified-p nil) RET
C-x C-s ; No file is written.

It's easy to change that flag for several buffers
with `Buffer-menu-not-modified' or
`ibuffer-do-toggle-modified'.  Then, if you plan to save those
buffers and if they have buffer-file-name nil, then you
are not offered to save them.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>From 2e0d336c4889fac79e5621be34e9149eb3064cce Mon Sep 17 00:00:00 2001
From: Tino Calancha <address@hidden>
Date: Tue, 7 Feb 2017 22:53:35 +0900
Subject: [PATCH] Save unmodified buffers not visiting a file yet

* lisp/files.el (save-buffer): Set modified flag non-nil before
'basic-save-buffer' call (Bug#25642).
---
 lisp/files.el | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lisp/files.el b/lisp/files.el
index b7d104853c..c651ef4ee6 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4822,6 +4822,9 @@ save-buffer
              (not noninteractive)
              (not save-silently))
        (message "Saving file %s..." (buffer-file-name)))
+    ;; Save it as well when unmodified but not visiting a file yet.
+    (unless (or modp (buffer-file-name))
+      (set-buffer-modified-p t))
     (basic-save-buffer (called-interactively-p 'any))
     (and modp (memq arg '(4 64)) (setq buffer-backed-up nil))))
 
-- 
2.11.0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.7)
 of 2017-02-07
Repository revision: c939075b81b2b06c5ec040d7039fd20433509273






reply via email to

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