# HG changeset patch # User Jay Belanger # Date 1248202595 0 # Node ID 671cf7805a1e5359f36d995687c7c26c84ff1233 # Parent d66fb2315dc00c56022657aed3aac8e1a02f9436 (calc-undo-length): New variable. (calc-quit): Truncate rather than eliminate `calc-undo-list'. diff -r d66fb2315dc0 -r 671cf7805a1e lisp/calc/calc.el --- 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))