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§
- Conceal
Rule - One compiled display-time elision rule.
Enums§
- Conceal
Rule Error - 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
ruleshide inline— sorted and coalesced. - rules_
version - A stamp identifying a rule set, for the matrix’s
concealaxis.