emacs-devel
[Top][All Lists]
Advanced

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

Re: undo in loaddefs.el buffer


From: Luc Teirlinck
Subject: Re: undo in loaddefs.el buffer
Date: Fri, 24 Dec 2004 15:39:53 -0600 (CST)

Joakim Verona wrote:

   When I work with tramp, for instance /su:address@hidden:/etc/hosts
   tramp asks me about "undo" information on each save, for the buffer
   *tram su root localhost* buffer.

   emacs asks me if I want to discard a number of bytes of undo
   information. This is very inconvenient.

This is caused by a recent change in undo, but I guess that it could
also be considered a bug in Tramp.

Juri Linkov wrote:

   Katsumi Yamaoka <address@hidden> writes:
   > You will receive many complaints in the near future.  Sigh.

   Right.  The same question is asked in auto-compression-mode during
   visiting large gzipped files.

I guess this could be considered a bug in auto-compression mode.

Moreover, in addition to those two and texinfo-format-buffer and
loaddefs.el, there is a problem when you autorevert the Buffer Menu.
At regular intervals, you get asked the "undo" question, even when the
Buffer Menu is very tiny (like three buffers).

   Even better not to ask anything, but to display a message saying that
   to prevent discarding the undo info the user should change the value
   of undo-outer-limit.

Or file a bug report.

There are several problems with the way various functions and packages
quite simply ignore undo completely and hence rely on the default
behavior of "undo", while it is completely inappropriate for them.

The current way to expose these various problems (by making them a lot
worse and hence more evident) indeed results in quite a bit of
inconvenience.

The problems with undo seem to be spread all over Emacs, but the
correct solution seems to vary and is not always obvious.  There are
programs that:

1.  Fail to disable undo in a buffer where undo is meaningless.

2.  Fail to discard old undo info that is no longer meaningful.

3.  Fail to put in undo boundaries, thus accumulating one huge single
    undo entry, eventually triggering the undo-outer-limit question.

Situation 3 seems to happen rather easily with timers.

>From (elisp)Undo:

     The editor command loop automatically creates an undo boundary
     before each key sequence is executed.

and:

     All buffer modifications add a boundary whenever the previous
     undoable change was made in some other buffer.

But it appears that a function called at regular intervals from a
timer and modifying a single buffer just accumulates one undo entry
that keeps growing until the limit is reached and the question is
asked.

Although the problem with the buffer menu appears to be caused by (3)
I believe that the reasons for discarding undo info when reverting a
file, also apply to reverting the Buffer Menu.  So the patch below,
discards all undo info when reverting the Buffer Menu.  Should the
same also apply to reverting Dired (which does not discard undo info
either)?

There are other ways to solve the "reverting the Buffer Menu" problem
than the one below and, moreover it is _not_ a general solution for
what _appears_ to be a general problem with timers.  I believe that
the patch below makes sense regardless.  I can install if desired.

===File ~/buff-menu.el-diff=================================
*** buff-menu.el        14 Dec 2004 07:57:14 -0600      1.78
--- buff-menu.el        23 Dec 2004 20:07:41 -0600      
***************
*** 207,213 ****
      (while (setq prop (next-single-property-change prop 'buffer))
        (when (eq (get-text-property prop 'buffer) oline)
        (goto-char prop)
!       (move-to-column ocol)))))
  
  (defun Buffer-menu-toggle-files-only (arg)
    "Toggle whether the current buffer-menu displays only file buffers.
--- 207,215 ----
      (while (setq prop (next-single-property-change prop 'buffer))
        (when (eq (get-text-property prop 'buffer) oline)
        (goto-char prop)
!       (move-to-column ocol))))
!   (or (eq buffer-undo-list t)
!       (setq buffer-undo-list nil)))
  
  (defun Buffer-menu-toggle-files-only (arg)
    "Toggle whether the current buffer-menu displays only file buffers.
============================================================




reply via email to

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