unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* undo weirdness with insert-file-contents
@ 2008-02-28  7:46 Miles Bader
  2008-02-28  9:56 ` martin rudalics
  2008-02-28 17:45 ` Glenn Morris
  0 siblings, 2 replies; 28+ messages in thread
From: Miles Bader @ 2008-02-28  7:46 UTC (permalink / raw)
  To: emacs-devel

I define a "message-setup-hook" which for some reason has the unintended
side-effect of turning off undo in the result message-mode buffer
[buffer-undo-list has a value of t].

I've tracked the problem down to a call to `insert-file-contents' in the
hook function; If I remove the call to insert-file-contents, undo
doesn't get turned off.

I looked at the C code for insert-file-contents, and its handling of the
undo list looks pretty messy, it seems to be saving it and restoring
multiple times (sometimes nested?) using multiple methods of restoring
the old value....

The following cut-down message-setup-hook illustrates the problem:

   (defvar file-to-insert "~/.profile")
   (defun test-message-setup-hook ()
     (save-excursion
       (insert "Foo: bar\n")
       (insert-file-contents file-to-insert)))
   (setq message-setup-hook nil)
   (add-hook 'message-setup-hook 'test-message-setup-hook)

[Substitute an appropriate filename for the value of the file-to-insert
variable; anything is OK as long as it exists and is readable.  I just
used "~/.profile" because it usually exists :-]

To test this, in "emacs -Q", evaluate the above code, and then do
"M-x message-mail RET" to start composing in message-mode.  Insert some
test and then try to undo it -- it should fail, because undo is turned
off in that buffer.

If you then do (setq message-setup-hook nil) and try
"M-x message-mail RET" again, undo should work properly this time.

Anyone know more about the treatment of bufer-undo-list in
insert-file-contents?

Thanks,

-Miles

-- 
Love is a snowmobile racing across the tundra.  Suddenly it flips over,
pinning you underneath.  At night the ice weasels come.  --Nietzsche




^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2008-03-08  9:55 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).