Skip to content

feat: provide narrowing scope as widget context - #70

Merged
d12frosted merged 1 commit into
masterfrom
feat/narrowing-scope-context
Aug 25, 2026
Merged

d12frosted merged 1 commit into
masterfrom
feat/narrowing-scope-context

Conversation

@d12frosted

Copy link
Copy Markdown
Owner

Follow-up to #69. The narrowing scope was internal, so a custom widget had no sane way to know the buffer is narrowed: no narrowing hook exists in Emacs, and the sidebar's answer to that (read buffer state during render, memo on it) relied on double-dash helpers with no stability promise.

Now the sidebar root computes the scope once per render pass and provides it as the vulpea-ui-scope context. Built-in widgets (backlinks, outline, stats) consume the context instead of each probing the buffer, so however many widgets follow narrowing, the org buffer is scanned once. vulpea-ui-narrowing-scope is public API.

A custom widget follows narrowing with one hook call and one memo dependency:

(let ((note (use-vulpea-ui-note))
      (scope (use-vulpea-ui-scope)))
  (vui-use-memo (note scope)
    (my-compute-data note scope)))

A widget that ignores the scope just stays file-scoped, so nothing changes for existing widgets in the wild. The README has a "Narrowing-aware widgets" section with the full recipe.

The sidebar root now computes the narrowing scope once per render
pass and shares it with every widget through the vulpea-ui-scope
context. Built-in widgets (backlinks, outline, stats) consume the
context instead of each probing the buffer, and the scope function is
public API now (vulpea-ui-narrowing-scope), so custom widgets can
follow narrowing with one hook call and one memo dependency:

  (let ((scope (use-vulpea-ui-scope)))
    (vui-use-memo (note scope) ...))

Documented as a recipe in the README.
@d12frosted
d12frosted merged commit 5bdc8cf into master Aug 25, 2026
2 checks passed
@d12frosted
d12frosted deleted the feat/narrowing-scope-context branch August 25, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant