map-extentswon’t traverse all of my extents!
I tried to use
map-extents to do an operation on all the extents
in a region. However, it seems to quit after processing a random number
of extents. Is it buggy?
No. The documentation of
map-extents states that it will iterate
across the extents as long as function returns
Unexperienced programmers often forget to return
which results in buggy code. For instance, the following code is
supposed to delete all the extents in a buffer, and issue as many
(map-extents (lambda (ext ignore) (delete-extent ext) (message "fubar!")))
Instead, it will delete only the first extent, and stop right there –
message will return a non-nil value. The correct code
(map-extents (lambda (ext ignore) (delete-extent ext) (message "fubar!") nil))