emacs-devel
[Top][All Lists]
Advanced

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

undo weirdness with insert-file-contents


From: Miles Bader
Subject: undo weirdness with insert-file-contents
Date: Thu, 28 Feb 2008 16:46:22 +0900

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




reply via email to

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