all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: undo weirdness with insert-file-contents
Date: Sun, 02 Mar 2008 23:05:12 +0100	[thread overview]
Message-ID: <47CB2498.1030405@gmx.at> (raw)
In-Reply-To: <jwvejatx89y.fsf-monnier+emacs@gnu.org>

 >>the empty_undo_list check at all.  BTW, what is the semantics of
 >>`insert-file-contents' with VISIT nil and REPLACE non-nil?
 >
 > It seems obvious to me that it's similar to "delete + insert".
 > So I guess I don't understand the question quite right.  I use this kind
 > of call to insert-file-contents in smerge-resolve, if you want to see
 > an example.

I asked because from reading the code I sometimes got the impression
that REPLACE => VISIT.

 >>>Also if the file is empty, is this going to mark the buffer as modified
 >>>even though nothing was changed?
 >
 >>I'm afraid I don't understand the question - do you mean the case where
 >>inserted equals zero?
 >
 > Yes.
 >
 >>I don't handle that.
 >
 > What does that mean?  Are you going to mark the buffer as modified?

Where do I mark a buffer as modified?  What I propose is to insert a
"first change" element in the undo list.  Is it that what you mean?

 > Normally record_first_change is called "automatically" elsewhere.
 > So why is it needed here?

Because it's _not_ done elsewhere.

 > The handling of the undo-list and modified-p status in
 > insert-file-contents is a real mess.

The main reason for the "mess" is that `insert-file-contents' has to
reconcile visiting a file and inserting the contents of some file into
an existing buffer.  In the first case the buffer should appear
unmodified and the undo-list empty after the insertion.  In the second
case the buffer should appear modified and the change recorded in the
undo list.

A second reason stems from the various decoding steps.  Ideally,
decoding should run transparently and only the "final" insertion get
recorded.  For this purpose you have to temporarily switch off undo
recording in the non-visiting case.  Otherwise, undoing changes could
reveal changes done by the decoding routine as can be observed with
Emacs 22.  Moreover, recording changes during decoding might be
expensive.

Finally, functions called by `insert-file-contents', for example,
`decode_coding' and `adjust_after_insert', may modify `buffer-undo-list'
in some way or the other.

 > It'd be good to take a step back
 > and think about how it *should* work.  E.g. I don't think
 > insert-file-contents should mess with modified-p: it should behave just
 > like a normal `insert' in this respect.

Its doc-string says "If second argument VISIT is non-nil, the buffer's
visited filename and last save file modtime are set, and it is marked
unmodified." hence we would have to change that first.

Maybe we could resolve these issues by renaming `insert-file-contents'
to `insert-file-contents-1' and having a new `insert-file-contents'
handle the undo list and the buffer-modified state while calling
`insert-file-contents-1' with undo disabled.





  reply	other threads:[~2008-03-02 22:05 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-28  7:46 undo weirdness with insert-file-contents Miles Bader
2008-02-28  9:56 ` martin rudalics
2008-02-28 11:01   ` Miles Bader
2008-02-28 13:12     ` martin rudalics
2008-02-28 16:52       ` Stefan Monnier
2008-02-28 19:31         ` martin rudalics
2008-02-28 20:01           ` Miles Bader
2008-02-28 22:19             ` martin rudalics
2008-02-28 21:35           ` Stefan Monnier
2008-02-28 22:21             ` martin rudalics
2008-02-28 17:45 ` Glenn Morris
2008-02-28 19:35   ` martin rudalics
2008-02-28 20:28     ` Glenn Morris
2008-02-28 22:20       ` martin rudalics
2008-02-29 22:42       ` martin rudalics
2008-03-02  5:02         ` Stefan Monnier
2008-03-02 12:44           ` martin rudalics
2008-03-02 19:07             ` Stefan Monnier
2008-03-02 22:05               ` martin rudalics [this message]
2008-03-03  2:15                 ` Stefan Monnier
2008-03-03  9:09                   ` martin rudalics
2008-03-03 21:03                     ` Stefan Monnier
2008-03-07  9:33                       ` martin rudalics
2008-03-07 22:04                         ` Stefan Monnier
2008-03-08  9:55                           ` martin rudalics
2008-03-02 22:18               ` Bill Wohler
2008-03-03  9:09                 ` martin rudalics
2008-02-29  5:50   ` Bill Wohler

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

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

  git send-email \
    --in-reply-to=47CB2498.1030405@gmx.at \
    --to=rudalics@gmx.at \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.
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.