help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is it ok to sort a list of overlays destructively?


From: Marcin Borkowski
Subject: Is it ok to sort a list of overlays destructively?
Date: Tue, 27 Jul 2021 07:22:42 +0200
User-agent: mu4e 1.1.0; emacs 28.0.50

Hi all,

I need to sort the list of overlays returned by `overlays-in'.  The docs
for that function do not says explicitly that it creates a new list
every time, although a cursory glance at its source says that it
apparently does.  (Also,

(eq (overlays-in (point-min) (point-max)) (overlays-in (point-min) (point-max)))

is nil also when there are overlays in the buffer, so it seems to be the
case.)  OTOH, if creating a new list every time isn't in the docs, one
shouldn't rely on it, no?

So, is it a good practice to

(sort (overlays-in (point-min) (point-max))
      (lambda (o1 o2)
        (< (overlay-start o1) (overlay-start o2))))

?

TIA,

-- 
Marcin Borkowski
http://mbork.pl



reply via email to

[Prev in Thread] Current Thread [Next in Thread]