[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to tell that buffer is not modifed?
From: |
Jean Louis |
Subject: |
Re: How to tell that buffer is not modifed? |
Date: |
Thu, 25 Mar 2021 12:59:21 +0300 |
User-agent: |
Mutt/2.0.6 (2021-03-06) |
* Eli Zaretskii <eliz@gnu.org> [2021-03-25 12:32]:
> > Date: Thu, 25 Mar 2021 11:53:36 +0300
> > From: Jean Louis <bugs@gnu.support>
> >
> > I would like to tell programmatically that buffer is not modified even
> > though it is modified.
>
> See the function set-buffer-modified-p.
Oh yes, thanks.
I have tried solving it by associating the file to buffer and then
disassociating, as that way `set-auto-mode' works.
(switch-to-buffer buffer)
(setq-local buffer-file-name filename-revised)
(read-only-mode 0)
(insert body)
(goto-char 1)
(set-auto-mode)
(setq-local buffer-file-name nil)
(read-only-mode 1)
Now it seem not good idea to use it with `set-buffer-modified-p'
(switch-to-buffer buffer)
(setq-local buffer-file-name filename-revised)
(read-only-mode 0)
(insert body)
(goto-char 1)
(set-auto-mode)
;; (setq-local buffer-file-name nil) ;; TODO
(set-buffer-modified-p nil) ;; TODO which one is better?
(read-only-mode 1)
as then if I wish to save the associated file but buffer is not
modified, saving is not easy, as Emacs thinks it was already saved.
It is solved.
I will let it be associated to versioned file number, if user wish to
save revision of a previous file, the associated file name is there
and user may save it.
Jean