1

When multiple-cursors is deactivated, I would like to remove from the buffer-undo-list all entries that look like this:

(apply activate-cursor-for-undo 40)

(apply deactivate-cursor-after-undo 38)

How can I remove all such entries in one fell swoop?

BACKGROUND: I am storing the buffer-undo-list and buffer-undo-tree in the desktop restore file, and I'd like to make it smaller so that Emacs will handle starting and shutting down more efficiently.

1 Answer 1

1

The following code fragment should do what you want:

(require 'cl-lib)
(setq buffer-undo-list
      (cl-remove-if (lambda (x) (and (consp x) (eq (car x) 'apply)
                     (setq x (cdr x))
                     (consp x) (memq (car x) '(activate-cursor-for-undo deactivate-cursor-after-undo))
                     (setq x (cdr x))
                     (consp x) (numberp (car x))))
            buffer-undo-list))

(Note, that this is not fully tested. Comments welcome.)

2
  • I changed deactivate-cursor-for-undo to deactivate-cursor-after-undo and the new list appears to be clean. I'll try using the cleaned list for a couple of hours today and see how it works.
    – lawlist
    Apr 16, 2017 at 23:22
  • @lawlist Thank you for testing and commenting. I corrected my answer according to your comment.
    – Tobias
    Apr 17, 2017 at 0:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.