Commit 89a6d3ef authored by Troels Henriksen's avatar Troels Henriksen
Browse files

Protect the undo history, even if an error is signalled somewhere.

parent bb837646
...@@ -107,16 +107,16 @@ ...@@ -107,16 +107,16 @@
(let ((buffer-var (gensym))) (let ((buffer-var (gensym)))
`(let ((,buffer-var ,buffer)) `(let ((,buffer-var ,buffer))
(setf (undo-accumulate ,buffer-var) '()) (setf (undo-accumulate ,buffer-var) '())
,@body (unwind-protect (progn ,@body)
(cond ((null (undo-accumulate ,buffer-var)) nil) (cond ((null (undo-accumulate ,buffer-var)) nil)
((null (cdr (undo-accumulate ,buffer-var))) ((null (cdr (undo-accumulate ,buffer-var)))
(add-undo (car (undo-accumulate ,buffer-var)) (add-undo (car (undo-accumulate ,buffer-var))
(undo-tree ,buffer-var))) (undo-tree ,buffer-var)))
(t (t
(add-undo (make-instance 'compound-record (add-undo (make-instance 'compound-record
:buffer ,buffer-var :buffer ,buffer-var
:records (undo-accumulate ,buffer-var)) :records (undo-accumulate ,buffer-var))
(undo-tree ,buffer-var))))))) (undo-tree ,buffer-var))))))))
(defmethod flip-undo-record :around ((record climacs-undo-record)) (defmethod flip-undo-record :around ((record climacs-undo-record))
(with-slots (buffer) record (with-slots (buffer) record
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment