changeset 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 d66fb2315dc0
children b72f956b39db
files lisp/calc/calc.el
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
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))