unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to tell that buffer is not modifed?
Date: Thu, 25 Mar 2021 12:59:21 +0300	[thread overview]
Message-ID: <YFxe+RbjaDlYpy5r@protected.localdomain> (raw)
In-Reply-To: <8335wjk2aw.fsf@gnu.org>

* 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



      reply	other threads:[~2021-03-25  9:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YFxe+RbjaDlYpy5r@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).