Function: restore-buffer-modified-p
restore-buffer-modified-p is a function defined in buffer.c.
Signature
(restore-buffer-modified-p FLAG)
Documentation
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. A special value of autosaved
will mark the buffer as modified and also as 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(var)/buffer-file-name(fun) are non-nil.
It is not ensured that mode lines will be updated to show the modified state of the current buffer. Use with care.
Probably introduced at or before Emacs version 29.1.
Aliases
verilog-restore-buffer-modified-p
Source Code
// Defined in /usr/src/emacs/src/buffer.c
{
/* If buffer becoming modified, lock the file.
If buffer becoming unmodified, unlock the file. */
struct buffer *b = current_buffer->base_buffer
? current_buffer->base_buffer
: current_buffer;
if (!inhibit_modification_hooks)
{
Lisp_Object fn = BVAR (b, file_truename);
/* Test buffer-file-name so that binding it to nil is effective. */
if (!NILP (fn) && ! NILP (BVAR (b, filename)))
{
bool already = SAVE_MODIFF < MODIFF;
if (!already && !NILP (flag))
Flock_file (fn);
else if (already && NILP (flag))
Funlock_file (fn);
}
}
/* Here we have a problem. SAVE_MODIFF is used here to encode
buffer-modified-p (as SAVE_MODIFF<MODIFF) as well as
recent-auto-save-p (as SAVE_MODIFF<auto_save_modified). So if we
modify SAVE_MODIFF to affect one, we may affect the other
as well.
E.g. if FLAG is nil we need to set SAVE_MODIFF to MODIFF, but
if SAVE_MODIFF<auto_save_modified that means we risk changing
recent-auto-save-p from t to nil.
Vice versa, if FLAG is non-nil and SAVE_MODIFF>=auto_save_modified
we risk changing recent-auto-save-p from nil to t. */
if (NILP (flag))
/* This unavoidably sets recent-auto-save-p to nil. */
SAVE_MODIFF = MODIFF;
else
{
/* If SAVE_MODIFF == auto_save_modified == MODIFF, we can either
decrease SAVE_MODIFF and auto_save_modified or increase
MODIFF. */
if (SAVE_MODIFF >= MODIFF)
SAVE_MODIFF = modiff_incr (&MODIFF, 1);
if (EQ (flag, Qautosaved))
BUF_AUTOSAVE_MODIFF (b) = MODIFF;
}
return flag;
}