> The doc string of `remove-overlays' doesn't make it precisely clear > what the criterion is for removing an overlay. Perhaps that criterion > needs to be changed. It is worth some thought. The doc-string of `remove-overlays' is not useful in this regard - its first sentence is silly. But `remove-overlays' relies on `overlays-in' and the latter's doc-string is precise. A zero-length overlay located at the (implicit) END arg of `remove-overlays' should _not_ get deleted unless it's located at the (implicit) BEG too. `remove-overlays' is more often used for the wrong purpose - to delete all overlays (with a given property) in a buffer. As I suggested earlier some form of `delete-all-overlays' would serve that purpose much better - in particular it wouldn't have to build and subsequently gc the intermediate list returned by `overlays-in'. Moreover it wouldn't have to recenter overlays and could be easily instructed to delete overlays with given properties only. OTOH `overlays-in' disregards overlay properties. This contrasts with its actual use in Emacs: The vast majority of `overlays-in' calls is followed by code checking whether the returned overlays match some specific property. This approach is highly inefficient when a buffer contains few overlays with property foo, many with property bar, and a client is looking for all overlays with property foo. `overlays-in' must investigate all overlays (find their start and end points, compare whether they fit into the region, maybe allocate an additional vector) and put them together in a list. The client has to filter the list returned and the collector has to recycle it. I attached an older patch I found useful in this context. `overlays-in' would get an additional optional parameter PROP and include an overlay iff either PROP is nil or its property list has an entry for PROP. `overlays-with-prop-eq-value' would get two additional parameters PROP and VALUE and include an overlay only if its PROP property eqs VALUE. People then could start to get rid of monstrosities like (let ((pos (point-min))) (while (< (setq pos (next-overlay-change pos)) (point-max)) (dolist (ol (overlays-at pos)) (if (overlay-get ol 'sgml-tag) (delete-overlay ol))))) in sgml-mode.