* How to tell that buffer is not modifed?
@ 2021-03-25 8:53 Jean Louis
2021-03-25 9:31 ` Eli Zaretskii
0 siblings, 1 reply; 3+ messages in thread
From: Jean Louis @ 2021-03-25 8:53 UTC (permalink / raw)
To: Help GNU Emacs
I would like to tell programmatically that buffer is not modified even
though it is modified.
I am inserting the database entry into the buffer, but because
`set-auto-mode' works only on buffers with associated file names, I am
assocating a file name with revision number. This association makes
buffer look modified and killing buffer asks for saving. I would like
to tell that buffer is not modified, as the information arrived from
database and it is anyway in a read only mode.
(switch-to-buffer (get-buffer-create buffer))
(setq-local buffer-file-name filename-revised)
(read-only-mode 0)
(insert body)
(goto-char 1)
(set-auto-mode)
(read-only-mode 1)))
Jean
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to tell that buffer is not modifed?
2021-03-25 8:53 How to tell that buffer is not modifed? Jean Louis
@ 2021-03-25 9:31 ` Eli Zaretskii
2021-03-25 9:59 ` Jean Louis
0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2021-03-25 9:31 UTC (permalink / raw)
To: help-gnu-emacs
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to tell that buffer is not modifed?
2021-03-25 9:31 ` Eli Zaretskii
@ 2021-03-25 9:59 ` Jean Louis
0 siblings, 0 replies; 3+ messages in thread
From: Jean Louis @ 2021-03-25 9:59 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
* 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-25 9:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-25 8:53 How to tell that buffer is not modifed? Jean Louis
2021-03-25 9:31 ` Eli Zaretskii
2021-03-25 9:59 ` Jean Louis
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.