From 06ee8ac36c9590ed028a3633a21a655104f772c8 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 20 Jul 2021 13:32:39 +0200 Subject: [PATCH] Mention `overlays-in' in the `overlays-at' doc string * src/buffer.c (Foverlays_at): Mention `overlays-in' in the doc string (bug#459). --- src/buffer.c | 6 +++++- test/src/buffer-tests.el | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/buffer.c b/src/buffer.c index d3a5ffd1491..335523de604 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -4222,7 +4222,11 @@ OVERLAY. */) DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 2, 0, doc: /* Return a list of the overlays that contain the character at POS. -If SORTED is non-nil, then sort them by decreasing priority. */) +If SORTED is non-nil, then sort them by decreasing priority. + +Zero-length overlays that start and stop at POS are not included in +the return value. Instead use `overlays-in' if those overlays are of +interest. */) (Lisp_Object pos, Lisp_Object sorted) { ptrdiff_t len, noverlays; diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el index 2adffc024a4..20f85c6c93e 100644 --- a/test/src/buffer-tests.el +++ b/test/src/buffer-tests.el @@ -1386,4 +1386,17 @@ with parameters from the *Messages* buffer modification." (when (buffer-live-p base) (kill-buffer base))))))) +(ert-deftest zero-length-overlays-and-not () + (with-temp-buffer + (insert "hello") + (let ((long-overlay (make-overlay 2 4)) + (zero-overlay (make-overlay 3 3))) + ;; Exclude. + (should (= (length (overlays-at 3)) 1)) + (should (eq (car (overlays-at 3)) long-overlay)) + ;; Include. + (should (= (length (overlays-in 3 3)) 2)) + (should (memq long-overlay (overlays-in 3 3))) + (should (memq zero-overlay (overlays-in 3 3)))))) + ;;; buffer-tests.el ends here -- 2.39.2