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.

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.

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.  */
  SAVE_MODIFF = (NILP (flag)
		 /* FIXME: This unavoidably sets recent-auto-save-p to nil.  */
		 ? MODIFF
		 /* Let's try to preserve recent-auto-save-p.  */
		 : SAVE_MODIFF < MODIFF ? SAVE_MODIFF
		 /* If SAVE_MODIFF == auto_save_modified == MODIFF,
		    we can either decrease SAVE_MODIFF and auto_save_modified
		    or increase MODIFF.  */
		 : modiff_incr (&MODIFF));

  return flag;
}