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 "Opzioni per eliminare la stringa commentata:
- [y] per eliminare la stringa con relativo \"newline\"
- [l] per eliminare la stringa mantenendo il \"newline\"
- [n] per mantenere la stringa commentata
- [q] per uscire da questo loop:
"))
(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 (remove-overlays b e)))
)
)
(read-string "UNWIND EXIT"))
(read-string "NORMAL EXIT")
)))
)
in which the unwind cleanup-form
is always evalueted, but I need it to be evaluate only when something goes wrong (e.g. a quit
of the script).
Where is my mistake? I thought it shouldn't be evaluate since the body form
of unwind-protect
exits normally.
The loop is meant to interactively remove some kinds of commented lines in LaTeX code, letting me choose if removing also the corresponding newline.