am_marks_at: Get marks at a specific position

View source: R/cursors.R

am_marks_atR Documentation

Get marks at a specific position

Description

Retrieves marks that include a specific position in a text object. This function efficiently filters marks at the C level, avoiding the overhead of converting all marks to R objects.

Usage

am_marks_at(obj, position)

Arguments

obj

An Automerge object ID (must be a text object)

position

Integer position (0-based inter-character position) to query. See am_mark() for indexing details.

Value

A list of marks that include the specified position. Returns an empty list if no marks cover that position.

Examples

doc <- am_create()
am_put(doc, AM_ROOT, "text", am_text("Hello World"))
text_obj <- am_get(doc, AM_ROOT, "text")

am_mark(text_obj, 0, 5, "bold", TRUE)
am_mark(text_obj, 2, 7, "underline", TRUE)

# Get marks at position 3 (inside "Hello")
marks_at_3 <- am_marks_at(text_obj, 3)
marks_at_3
# List of 2 marks (both "bold" and "underline" include position 3)

am_close(doc)


automerge documentation built on Feb. 5, 2026, 5:08 p.m.