diff lisp/calc/calc.el @ 104010:671cf7805a1e

(calc-undo-length): New variable. (calc-quit): Truncate rather than eliminate `calc-undo-list'.
author Jay Belanger <jay.p.belanger@gmail.com>
date Tue, 21 Jul 2009 18:56:35 +0000
parents 70bd50ad24da
children 2afab32ae92d
line wrap: on
line diff
--- a/lisp/calc/calc.el	Tue Jul 21 14:49:36 2009 +0000
+++ b/lisp/calc/calc.el	Tue Jul 21 18:56:35 2009 +0000
@@ -417,6 +417,12 @@
   :group 'calc
   :type 'boolean)
 
+(defcustom calc-undo-length 
+  100
+  "The number of undo steps that will be preserved when Calc is quit."
+  :group 'calc
+  :type 'integer)
+
 (defvar calc-bug-address "jay.p.belanger@gmail.com"
   "Address of the maintainer of Calc, for use by `report-calc-bug'.")
 
@@ -1485,7 +1491,14 @@
       (unless (eq major-mode 'calc-mode)
         (calc-create-buffer))
       (run-hooks 'calc-end-hook)
-      (setq calc-undo-list nil calc-redo-list nil)
+      (if (integerp calc-undo-length)
+          (cond
+           ((= calc-undo-length 0)
+            (setq calc-undo-list nil calc-redo-list nil))
+           ((> calc-undo-length 0)
+            (let ((tail (nthcdr (1- calc-undo-length) calc-undo-list)))
+              (if tail (setcdr tail nil)))
+            (setq calc-redo-list nil))))
       (mapc (function (lambda (v) (set-default v (symbol-value v))))
 	    calc-local-var-list)
       (let ((buf (current-buffer))