From 2de6c9c40370e664df706f42f56eadc6b5e2c21d Mon Sep 17 00:00:00 2001 From: Greg Sexton Date: Sat, 16 Aug 2014 19:07:20 +0100 Subject: [PATCH] Size limit and protect edges in history --- origami.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/origami.el b/origami.el index f2b04b8..9ce94cb 100644 --- a/origami.el +++ b/origami.el @@ -273,30 +273,30 @@ with the current state and the current node at each iteration." ;;; linear history structure -;;; TODO: size-limiting of past and future -;;; TODO: check for nils - (defun origami-h-new (present) "Create a new history structure." (vector nil present nil)) (defun origami-h-push (h new) "Create a new history structure with new as the present value." - (let ((past (aref h 0)) - (present (aref h 1))) - (vector (cons present past) new nil))) + (when new + (let ((past (aref h 0)) + (present (aref h 1))) + (vector (cons present (-take 19 past)) new nil)))) (defun origami-h-undo (h) (let ((past (aref h 0)) (present (aref h 1)) (future (aref h 2))) - (vector (cdr past) (car past) (cons present future)))) + (if (null past) h + (vector (cdr past) (car past) (cons present future))))) (defun origami-h-redo (h) (let ((past (aref h 0)) (present (aref h 1)) (future (aref h 2))) - (vector (cons present past) (car future) (cdr future)))) + (if (null future) h + (vector (cons present past) (car future) (cdr future))))) (defun origami-h-present (h) (when h (aref h 1)))