It is very simple to define a simple generalized setter for buffer-modified-p
:
(gv-define-simple-setter buffer-modified-p set-buffer-modified-p)
That enables constructs like:
(with-current-buffer "test.cc"
(cl-letf (((buffer-modified-p) t))
(save-buffer)))
If test.cc
is out-of-sync it is saved even if (buffer-modified-p)
returns nil. The old status of (buffer-modified-p)
is unconditionally restored afterwards.
I use that in a special case where there is a special save function which unsets buffer-modified-p
but does not save the buffer in the file associated with buffer-file-name
.
Question: Is that generalized setter already defined in some existing library?
Note, I know about with-buffer-modified-unmodified
from bookmarks.el
. But, that is not quite what I want.
C-h v
help could/should mention the known setter(s). If you think so, maybe file an enhancement request (?).