Skip to main content

Module conceal

Module conceal 

Source
Expand description

Conceal rules — the per-language declaration of what to hide.

A rule is a regex over one line plus the 1-based capture groups whose spans are elided. Org’s link rendering is two of them and nothing else; the mechanism, the coordinate maths and the mode scoping are the host’s.

Design anchor: docs/dev/architecture/conceal.md.

§Why regex and not fancy-regex

The workspace carries both: fancy-regex for /, ? and :s, where users expect lookaround, and regex for everything that must not backtrack. Conceal patterns run against every rebuilt display line, supplied by a plugin, so a catastrophic backtracking pattern would be a plugin’s ability to freeze the renderer. regex’s RE2-style engine has no such input, which turns “don’t ship a pathological pattern” from a plugin-author obligation into something they cannot do.

§Why a bad rule is dropped rather than fatal

A malformed tree-sitter query rejects the whole language (LanguageRegistrationError::QueryCompile), and that asymmetry is deliberate rather than an oversight. A broken folds.scm means the language cannot fold at all — structural, and silence there is indistinguishable from the feature not existing. A broken conceal rule means one pattern does not hide, the other rules are unaffected, and the language is otherwise entirely usable. Losing org over a typo in a cosmetic regex would be the disproportionate answer.

Structs§

ConcealRule
One compiled display-time elision rule.

Enums§

ConcealRuleError
Why one rule was refused.

Constants§

MAX_CONCEAL_PATTERN_LEN
The longest pattern accepted, in bytes. Compilation cost and per-line match cost both scale with program size, and no legitimate line-level rule comes close.
MAX_CONCEAL_RULES
The most rules one language may declare.

Functions§

compile_rule
Compile one rule, or say precisely why not.
compile_rule_styled
OL.1: compile_rule, plus the style its visible remainder takes.
compile_rules
Compile a language’s whole declaration, keeping what works.
conceal_spans
conceal_style_spans
The byte ranges rules hide in line — sorted and coalesced.
rules_version
A stamp identifying a rule set, for the matrix’s conceal axis.