From: Jay Belanger Date: Tue, 21 Jul 2009 18:56:35 +0000 (+0000) Subject: (calc-undo-length): New variable. X-Git-Tag: emacs-pretest-23.1.90~2078 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b159e5b04752be4702b1f0da6565c4837d711757;p=emacs.git (calc-undo-length): New variable. (calc-quit): Truncate rather than eliminate `calc-undo-list'. --- diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el index 78513c891f6..704209d7680 100644 --- a/lisp/calc/calc.el +++ b/lisp/calc/calc.el @@ -417,6 +417,12 @@ in normal mode." :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 @@ commands given here will actually operate on the *Calculator* stack." (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))