]> git.eshelyaron.com Git - emacs.git/commitdiff
Mention `overlays-in' in the `overlays-at' doc string
authorLars Ingebrigtsen <larsi@gnus.org>
Tue, 20 Jul 2021 11:32:39 +0000 (13:32 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Tue, 20 Jul 2021 11:32:39 +0000 (13:32 +0200)
* src/buffer.c (Foverlays_at): Mention `overlays-in' in the doc
string (bug#459).

src/buffer.c
test/src/buffer-tests.el

index d3a5ffd1491e85e6eb7b0d475d47edbdc87aedd1..335523de604dd0bbab4a57f036a89aba889cf669 100644 (file)
@@ -4222,7 +4222,11 @@ OVERLAY.  */)
 \f
 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;
index 2adffc024a4c81eb8920ef46a765e0fee352f7c9..20f85c6c93ef95b5d67becbee15834ea485f2fc3 100644 (file)
@@ -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