emacs-diffs
[Top][All Lists]
Advanced

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

master 06ee8ac: Mention `overlays-in' in the `overlays-at' doc string


From: Lars Ingebrigtsen
Subject: master 06ee8ac: Mention `overlays-in' in the `overlays-at' doc string
Date: Tue, 20 Jul 2021 07:32:47 -0400 (EDT)

branch: master
commit 06ee8ac36c9590ed028a3633a21a655104f772c8
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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 d3a5ffd..335523d 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 2adffc0..20f85c6 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



reply via email to

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