My goal is to delete all duplicate overlay values from a list, and then remove every overlay in the buffer with values equal to each remaining element in the list.
I am having trouble understanding why remove-overlays
does not remove every overlay in the buffer containing a specific value. What appears to be happening is that remove-overlays
removes just the first overlay it finds matching that specific value, and then it moves on to the next task without deleting the remainder of overlays with that same value.
I would like to delete duplicate values from the list using (delq nil (delete-dups ov-list))
.
EXAMPLE
A test buffer contains the following text on the first line in the buffer:
############################
The code I am using is as follows:
(let* (ov-value ov-list overlay limit char-at-point)
(save-excursion
(goto-char (point-min))
(setq limit (point-at-eol))
(while (re-search-forward "#" limit t)
(setq character (char-after (point)))
(setq overlay (make-overlay (point) (1+ (point))))
(setq ov-value (concat
(propertize (char-to-string ?\uFEFF) 'face '(:background "yellow"))
(propertize (char-to-string character) 'face '(:foreground "green"))))
(push ov-value ov-list)
(overlay-put overlay 'display ov-value)))
(sit-for 2)
(delq nil (delete-dups ov-list))
(dolist (ov ov-list)
(remove-overlays nil nil 'display ov)))