Repository navigation
feat: provide narrowing scope as widget context - #70
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.