[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 1642a5ffcd: Adjust restore-buffer-modified-p autosaved logic
From: |
Lars Ingebrigtsen |
Subject: |
master 1642a5ffcd: Adjust restore-buffer-modified-p autosaved logic |
Date: |
Wed, 11 May 2022 20:16:53 -0400 (EDT) |
branch: master
commit 1642a5ffcdf734c629e5aec963a0b190997704d6
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>
Adjust restore-buffer-modified-p autosaved logic
* doc/lispref/buffers.texi (Buffer Modification): Adjust
documentation.
* src/buffer.c (Frestore_buffer_modified_p): Fix up the logic
around `autosaved': It means "the buffer is modified, and also
autosaved".
---
doc/lispref/buffers.texi | 6 +++---
src/buffer.c | 12 ++++++------
test/src/buffer-tests.el | 10 ++++++++++
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index 2e5771f347..9f3808a45b 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -565,9 +565,9 @@ function @code{force-mode-line-update} works by doing this:
@end defun
@defun restore-buffer-modified-p flag
-Like @code{set-buffer-modified-p}, but does not force redisplay
-of mode lines. This function also allows a @var{flag} value of
-@code{autosaved}, which marks the buffer as having been autosaved
+Like @code{set-buffer-modified-p}, but does not force redisplay of
+mode lines. This function also allows a @var{flag} value of
+@code{autosaved}, which also marks the buffer as having been autosaved
after the last modification.
@end defun
diff --git a/src/buffer.c b/src/buffer.c
index 0af14a1060..89b04a4280 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1448,9 +1448,9 @@ DEFUN ("restore-buffer-modified-p",
Frestore_buffer_modified_p,
Srestore_buffer_modified_p, 1, 1, 0,
doc: /* Like `set-buffer-modified-p', but doesn't redisplay buffer's
mode line.
A nil FLAG means to mark the buffer as unmodified. A non-nil FLAG
-means mark the buffer as modified, but the special value
-`autosaved' will instead mark the buffer as having been
-autosaved since it was last modified.
+means mark the buffer as modified. A special value of `autosaved'
+will mark the buffer modified, and also as having been autosaved since
+it was last modified.
This function also locks or unlocks the file visited by the buffer,
if both `buffer-file-truename' and `buffer-file-name' are non-nil.
@@ -1496,13 +1496,13 @@ state of the current buffer. Use with care. */)
SAVE_MODIFF = MODIFF;
else
{
- if (EQ (flag, Qautosaved))
- BUF_AUTOSAVE_MODIFF (b) = MODIFF;
/* If SAVE_MODIFF == auto_save_modified == MODIFF, we can either
decrease SAVE_MODIFF and auto_save_modified or increase
MODIFF. */
- else if (SAVE_MODIFF >= MODIFF)
+ if (SAVE_MODIFF >= MODIFF)
SAVE_MODIFF = modiff_incr (&MODIFF);
+ if (EQ (flag, Qautosaved))
+ BUF_AUTOSAVE_MODIFF (b) = MODIFF;
}
return flag;
}
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index 10dac68f9f..f6a18acaa6 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -1515,6 +1515,16 @@ with parameters from the *Messages* buffer modification."
(should (eq (buffer-modified-p) 'autosaved))
(insert "zot")
(restore-buffer-modified-p 'autosaved)
+ (should (eq (buffer-modified-p) 'autosaved))))
+
+ (ert-with-temp-file file
+ (with-current-buffer (find-file file)
+ (auto-save-mode 1)
+ (should-not (buffer-modified-p))
+ (insert "foo")
+ (should (buffer-modified-p))
+ (should-not (eq (buffer-modified-p) 'autosaved))
+ (restore-buffer-modified-p 'autosaved)
(should (eq (buffer-modified-p) 'autosaved)))))
;;; buffer-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 1642a5ffcd: Adjust restore-buffer-modified-p autosaved logic,
Lars Ingebrigtsen <=