At Sat, 19 Jul 2008 08:27:21 -0700, Carsten Dominik wrote: > > > On Jul 18, 2008, at 7:19 AM, Max Mikhanosha wrote: > > > If I press 't' in the agenda buffer and the state change is logged > > with a note, undo in the agenda buffer only undoes a note line in the > > org buffer, leaving the item state changed, and now being out of sync > > with agenda. > > > > If there is no note, then undo works fine. > > > Hmmm. yes. This is hard to fix, but I will take a look. >
I've tried to fix it myself, and yes its non-trivial because one has to adjust the undo boundary somehow after addinga a note.. After a few hours of hacking I gave up on that, and instead came up with the following: You seem to be playing with (undo-boundary) which records nil in the buffer-undo-list, which makes (undo-more) stop. It seems that one can use arbitrary markers in the undo list, not just nil. The (primitive-undo) function ignores anything in the undo list that is not a consp. Therefore the following code that implements named/storable undo-boundaries seems to work, you can test it in scratch buffer (defun make-undo-checkpoint () (let ((checkpoint (gensym))) (push checkpoint buffer-undo-list) checkpoint)) (defun do-undo-until-checkpoint (checkpoint) (let ((ptr buffer-undo-list) prev found rest-of-undo) (while (and ptr (not found)) (if (not (eq (car ptr) checkpoint)) (setq prev ptr ptr (cdr ptr)) (setq found t))) (when found ;; rest of undo list after our tag (setq rest-of-undo (cdr ptr)) ;; split the undo list by putting NIL at the place of ;; our tag (if (not prev) (setq buffer-undo-list nil)) ;; our tag was the 1st element (setcdr prev nil) ;; previous elemen is now last (undo-start) (while (listp pending-undo-list) (undo-more 1))))) (defvar checkpoints nil) (make-variable-buffer-local 'checkpoints) (defun record-undo-checkpoint (&optional arg) (interactive) (push (make-undo-checkpoint) checkpoints)) (defun undo-until-checkpoint (&optional arg) (interactive) (do-undo-until-checkpoint (pop checkpoints))) Now if you do M-x record-undo-checkpoint in the buffer it pushes into a stack of undo checkpoints. The M-x undo-until-checkpoint does undo until that checkpoint. The checkpoint itself is a unique gensym. Would it be possible to use this in the org-agenda undo functionality? You can simply create an undo checkpoint before doing any agenda command, and then call (undo-until-checkpoint) and it will undo all the changes in between regardless of undo boundaries? Regards, Max _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode