[climacs-cvs] CVS climacs
thenriksen
thenriksen at common-lisp.net
Fri Jul 21 06:25:45 UTC 2006
Update of /project/climacs/cvsroot/climacs
In directory clnet:/tmp/cvs-serv17972
Modified Files:
pane.lisp gui.lisp
Log Message:
Changed `with-undo' so undo works properly for commands that modify
buffers that were not the current buffer when the command loop
started. A single undo operation still cannot undo for multiple
buffers, however, so the user will have to manually invoke undo for
each buffer.
--- /project/climacs/cvsroot/climacs/pane.lisp 2006/07/06 17:31:50 1.44
+++ /project/climacs/cvsroot/climacs/pane.lisp 2006/07/21 06:25:45 1.45
@@ -103,20 +103,28 @@
:objects (buffer-sequence buffer offset (+ offset n)))
(undo-accumulate buffer))))
-(defmacro with-undo ((buffer) &body body)
- (let ((buffer-var (gensym)))
- `(let ((,buffer-var ,buffer))
- (setf (undo-accumulate ,buffer-var) '())
- (unwind-protect (progn , at body)
- (cond ((null (undo-accumulate ,buffer-var)) nil)
- ((null (cdr (undo-accumulate ,buffer-var)))
- (add-undo (car (undo-accumulate ,buffer-var))
- (undo-tree ,buffer-var)))
- (t
- (add-undo (make-instance 'compound-record
- :buffer ,buffer-var
- :records (undo-accumulate ,buffer-var))
- (undo-tree ,buffer-var))))))))
+(defmacro with-undo ((get-buffers-exp) &body body)
+ "Evaluate `body', registering any changes to buffer contents in
+the undo memory for the respective buffer, permitting individual
+undo for each buffer. `get-buffers-exp' should be a form, that
+will be evaluated whenever a complete list of buffers is
+needed (to set up all buffers to prepare for undo, and to check
+them all for changes after `body' has run)."
+ (let ((buffer-sym (gensym)))
+ `(progn
+ (dolist (,buffer-sym ,get-buffers-exp)
+ (setf (undo-accumulate ,buffer-sym) '()))
+ (unwind-protect (progn , at body)
+ (dolist (,buffer-sym ,get-buffers-exp)
+ (cond ((null (undo-accumulate ,buffer-sym)) nil)
+ ((null (cdr (undo-accumulate ,buffer-sym)))
+ (add-undo (car (undo-accumulate ,buffer-sym))
+ (undo-tree ,buffer-sym)))
+ (t
+ (add-undo (make-instance 'compound-record
+ :buffer ,buffer-sym
+ :records (undo-accumulate ,buffer-sym))
+ (undo-tree ,buffer-sym)))))))))
(defmethod flip-undo-record :around ((record climacs-undo-record))
(with-slots (buffer) record
--- /project/climacs/cvsroot/climacs/gui.lisp 2006/07/11 14:20:20 1.220
+++ /project/climacs/cvsroot/climacs/gui.lisp 2006/07/21 06:25:45 1.221
@@ -299,7 +299,7 @@
(handler-case
(progn
(if (buffer-pane-p current-window)
- (with-undo ((buffer current-window))
+ (with-undo ((buffers frame))
(call-next-method))
(call-next-method))
(loop for buffer in (buffers frame)
More information about the Climacs-cvs
mailing list