emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: Undo discard prompt (was: [T. V. Raman] read-only modes should be us


From: Luc Teirlinck
Subject: Re: Undo discard prompt (was: [T. V. Raman] read-only modes should be using buffer-disable-undo?)
Date: Tue, 25 Jan 2005 19:19:39 -0600 (CST)

There is one major new problem I discovered with the prompting as a
response to accumulating a large undo entry.

If the large undo entry is accumulated by a timer or asynchronous
process, the user may not even be at his monitor when the question is
asked.  The question has no built-in time out.  What happens now is
that the timer or asynchronous process might keep running at regular
intervals and continue to grow the undo entry, until Emacs potentially
crashes.

One solution might be to ask the question within a `with-timeout'
form.  However, I do not know enough about GC to know whether it is
really safe (for other reasons) to allow timers to run, or accept
asynchronous output (by asking a user question) while a GC is being
performed, even with a time-out.

It seems that the easiest solution would be to just discard the undo
info if it exceeds `undo-outer-limit', print a warning, and tell the
user to increase the value of `undo-outer-limit' to avoid this in the
future, if the large undo entry was legitimate.  I reread the report
that lead to all of this and what I just described appears to be all
the OP really wanted anyway.

Of course the above assumes that `undo-outer-limit' be made into a
defcustom, but I believe that should be done anyway, because the best
value depends on the resident memory the user has available, on his
habits and his personal preference.  The patch below to cus-start.el
does this.  It does allow the user to select "No limit" (nil) but
clearly warns about the dangers and discourages it.

The suitability of the changes I proposed earlier depend on what we
decide to do with the above, so I will wait with further suggestions
about those until the above issues are decided.

===File ~/cus-start.el-diff=================================
*** cus-start.el        23 Nov 2004 15:09:19 -0600      1.62
--- cus-start.el        25 Jan 2005 18:57:54 -0600      
***************
*** 41,46 ****
--- 41,55 ----
             (gc-cons-threshold alloc integer)
             (undo-limit undo integer)
             (undo-strong-limit undo integer)
+            (undo-outer-limit undo (choice integer
+                                           (const :tag "No limit"
+                                                  :format "%t\n%d"
+                                                  :doc
+                                                  "This should only be chosen 
under exceptional circumstances.
+ With this choice the undo info for the current command never gets discarded.
+ This could result in memory overflow and make Emacs crash."
+                                                  nil))
+                              "21.4")
             (garbage-collection-messages alloc boolean)
             ;; buffer.c
             (mode-line-format modeline sexp) ;Hard to do right.
============================================================




reply via email to

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