emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: insert-file-contents and format-decode


From: martin rudalics
Subject: Re: insert-file-contents and format-decode
Date: Sat, 30 Jun 2007 13:11:51 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

>      >     (2) `insert-file-contents' with `visit-flag' nil
>      >
>      > This is the case where it is desirable to make just one undo entry for
>      > the file contents as finally decoded.
>      >
>      >     (3) functions within format.el (and maybe other functions)
>      >
>      > For this case, they should do nothing special about undo.
>      > The primitives they call should make undo entries normally.
>
>     The problem is that I have to communicate this information in my call to
>     `format-decode'.  Currently we have no way to distinguish cases (2) and
>     (3) both have `visit-flag' nil.
>
> In case 2, `insert-file-contents' can turn off undo around the call to
> `format-decode', and make a single undo entry later on.  In case 1,
> `insert-file-contents' can turn off undo around the call to
> `format-decode', and not make any undo entry later on.
>
> Thus, `format-decode' itself should not do anything special about undo
> in any of the three cases.

I currently run this in `insert-file-contents' once around the entire
call sequence for `format-decode' and `after-insert-file-functions'.
Do we want undo boundaries before and/or after the insertion?

However, I'm not sure whether handling undo in `insert-file-contents'
contradicts parts of an earlier thread of our discussion:

>      > Is your suggestion to fix this by disabling the modification hooks in
>      > Finsert_file_contents around the call to `format-decode'?
>
>     Either in Finsert_file_contents or within `format-decode'.
>
> I think it is ok to disable them unconditionally inside `format-decode'.
> Decoding is sufficiently low level that it probably makes no sense
> to expect them to run these hooks.
>
> Then Finsert_file_contents can run the hooks just once for the
> (decoded) text that is ultimately inserted.

I suppose we do not want to disable the hooks for the "non-insert-file"
case, for example, interactive uses of `format-decode-region'.  Hence,
your suggestion to handle undo in `insert-file-contents' implies that we
have to disable these hooks in `insert-file-contents' too.  If,
alternatively, we wanted to disable them within `format-decode' we'd
have to run them in `format-decode-buffer' and `format-decode-region'
explicitly after calling `format-decode'.

Finally, I'm completely uncertain what to do about `format-insert-file':
That function explicitly prompts for a format and does `format-decode'
after inserting the file and running any `after-insert-file-functions'.
Shall we treat this is as a sequence of

(insert-file-contents filename nil beg end)

(let ((format-alist nil))
  (format-decode-region (point) (+ (point) size) format))

with _two_ `buffer-undo-list' entries and `after-change-functions'
calls?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]