I have this loop:
(catch 'QUIT (while (search-forward-regexp "\\([^\n\\]\\(?:\\\\\\\\\\)*\\|^\\(?:\\\\\\\\\\)+\\)%.*\n" nil t) (save-excursion (let ((b (make-marker)) (e (make-marker)) MatchedStringOverlay ACTION) (set-marker b (match-beginning 0)) (set-marker e (point)) (setq MatchedStringOverlay (make-overlay b e)) (unwind-protect (progn (overlay-put MatchedStringOverlay 'face '(:background "OliveDrab1")) (setq ACTION (read-char "Options: - [y] erase string and the corresponding \"newline\" - [l] erase string keeping the corresponding \"newline\" - [n] skip - [q] quit: ")) (cond ((char-equal ACTION ?y) (replace-match "\\1")) ((char-equal ACTION ?l) (replace-match "\\1\n")) ((char-equal ACTION ?n) nil) ((char-equal ACTION ?q) (throw 'QUIT nil)) ) ) (remove-overlays b e)) ))) )
that performs some interactive replacements on buffer.
Now it happens that when I do
undo after the loop, the command "undoes" all the replacements I made within the loop. How can I make each replacement a "single item" in
Please, do not blame me... I'm really trying to find the infos by myself. I've searched in the docs, in the internet and I red the code of
undo command but I've not been able to find how to get what I need.
EDIT. I think I shoud add a
buffer-undo-list to mark the boundary between two change groups (see here). So I tried
(add-to-list 'buffer-undo-list nil)
just before the first
cond group but it does not work.