1 |
;; Calculator for GNU Emacs, part II [calc-undo.el] |
;; Calculator for GNU Emacs, part II [calc-undo.el] |
2 |
;; Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc. |
;; Copyright (C) 1990, 1991, 1992, 1993, 2001 Free Software Foundation, Inc. |
3 |
;; Written by Dave Gillespie, daveg@synaptics.com. |
;; Written by Dave Gillespie, daveg@synaptics.com. |
4 |
|
|
5 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
49 |
(let ((calc-stack-top 0)) |
(let ((calc-stack-top 0)) |
50 |
(calc-handle-undos calc-undo-list n)) |
(calc-handle-undos calc-undo-list n)) |
51 |
(setq calc-stack-top saved-stack-top)))) |
(setq calc-stack-top saved-stack-top)))) |
52 |
(message "Undo!"))) |
(message "Undo!")))) |
|
) |
|
53 |
|
|
54 |
(defun calc-handle-undos (cl n) |
(defun calc-handle-undos (cl n) |
55 |
(if (> n 0) |
(if (> n 0) |
58 |
(setq calc-undo-list nil) |
(setq calc-undo-list nil) |
59 |
(calc-handle-undo (car cl)) |
(calc-handle-undo (car cl)) |
60 |
(setq calc-redo-list (append calc-undo-list old-redo))) |
(setq calc-redo-list (append calc-undo-list old-redo))) |
61 |
(calc-handle-undos (cdr cl) (1- n)))) |
(calc-handle-undos (cdr cl) (1- n))))) |
|
) |
|
62 |
|
|
63 |
(defun calc-handle-undo (list) |
(defun calc-handle-undo (list) |
64 |
(and list |
(and list |
86 |
(calc-record-undo (append (list 'eval (nth 2 action) (nth 1 action)) |
(calc-record-undo (append (list 'eval (nth 2 action) (nth 1 action)) |
87 |
(cdr (cdr (cdr action))))) |
(cdr (cdr (cdr action))))) |
88 |
(apply (nth 1 action) (cdr (cdr (cdr action)))))) |
(apply (nth 1 action) (cdr (cdr (cdr action)))))) |
89 |
(calc-handle-undo (cdr list)))) |
(calc-handle-undo (cdr list))))) |
|
) |
|
90 |
|
|
91 |
(defun calc-redo (n) |
(defun calc-redo (n) |
92 |
(interactive "p") |
(interactive "p") |
104 |
(let ((calc-stack-top 0)) |
(let ((calc-stack-top 0)) |
105 |
(calc-handle-redos calc-redo-list n)) |
(calc-handle-redos calc-redo-list n)) |
106 |
(setq calc-stack-top saved-stack-top)))) |
(setq calc-stack-top saved-stack-top)))) |
107 |
(message "Redo!"))) |
(message "Redo!")))) |
|
) |
|
108 |
|
|
109 |
(defun calc-handle-redos (cl n) |
(defun calc-handle-redos (cl n) |
110 |
(if (> n 0) |
(if (> n 0) |
113 |
(setq calc-undo-list nil) |
(setq calc-undo-list nil) |
114 |
(calc-handle-undo (car cl)) |
(calc-handle-undo (car cl)) |
115 |
(setq calc-undo-list (append calc-undo-list old-undo))) |
(setq calc-undo-list (append calc-undo-list old-undo))) |
116 |
(calc-handle-redos (cdr cl) (1- n)))) |
(calc-handle-redos (cdr cl) (1- n))))) |
|
) |
|
117 |
|
|
118 |
(defun calc-last-args (n) |
(defun calc-last-args (n) |
119 |
(interactive "p") |
(interactive "p") |
123 |
(let ((urec (calc-find-last-x calc-undo-list n))) |
(let ((urec (calc-find-last-x calc-undo-list n))) |
124 |
(if urec |
(if urec |
125 |
(calc-handle-last-x urec) |
(calc-handle-last-x urec) |
126 |
(error "Not enough undo information available")))) |
(error "Not enough undo information available"))))) |
|
) |
|
127 |
|
|
128 |
(defun calc-handle-last-x (list) |
(defun calc-handle-last-x (list) |
129 |
(and list |
(and list |
131 |
(if (eq (car action) 'pop) |
(if (eq (car action) 'pop) |
132 |
(calc-pop-push-record-list 0 "larg" |
(calc-pop-push-record-list 0 "larg" |
133 |
(delq 'top-of-stack (nth 2 action)))) |
(delq 'top-of-stack (nth 2 action)))) |
134 |
(calc-handle-last-x (cdr list)))) |
(calc-handle-last-x (cdr list))))) |
|
) |
|
135 |
|
|
136 |
(defun calc-find-last-x (ul n) |
(defun calc-find-last-x (ul n) |
137 |
(and ul |
(and ul |
139 |
(if (<= n 1) |
(if (<= n 1) |
140 |
(car ul) |
(car ul) |
141 |
(calc-find-last-x (cdr ul) (1- n))) |
(calc-find-last-x (cdr ul) (1- n))) |
142 |
(calc-find-last-x (cdr ul) n))) |
(calc-find-last-x (cdr ul) n)))) |
|
) |
|
143 |
|
|
144 |
(defun calc-undo-does-pushes (list) |
(defun calc-undo-does-pushes (list) |
145 |
(and list |
(and list |
146 |
(or (eq (car (car list)) 'pop) |
(or (eq (car (car list)) 'pop) |
147 |
(calc-undo-does-pushes (cdr list)))) |
(calc-undo-does-pushes (cdr list))))) |
|
) |
|
|
|
|
|
|
|
148 |
|
|
149 |
|
;;; calc-undo.el ends here |