Branch a branch out into a document of its own (stage 9b)

<Space>o (the user's pick), :branchout [file] or the right-click menu
moves the cursor's branch into a new document, next to this one and
named after the branch's title (-2 when that's taken), or at the path
given. Its top node becomes the root, in the middle of the canvas, and
the nodes keep their ids, so the links among them, the small and capital
marks on them and the jump lists still find them.

A portal to the new document takes the branch's place (same spot in the
tree and on the canvas, same branch line) as one undo step, with a new
EditOp::BranchOut; u brings the branch back while the new file stays on
disk, as after :new. Then the pane goes through the portal (the user's
pick), so Ctrl-o comes back and the breadcrumb starts with the document
it came from.

Portals inside the branch move along (the user's pick), their paths made
from the new file's folder, and their documents' backlinks follow. Links
between the branch and the rest can't follow, since links stay inside a
document, and the message counts them. The root and portals themselves
can't branch out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
skkeyeandClaude Opus 5.5 committed 2026-10-02 11:25:57 -04:00
1 parent 3b8f7c0b3c
commit 5888d143fd
19 files changed
+343 -13

No files matched your search

+4 -2
View File
@@ -84,7 +84,9 @@ pub enum Call {
Link(NodeId),
Unlink(Option<NodeId>),
Portal(String),
BranchOut,
/// A branch into a document of its own, at this path (or next to this
/// one, named after it).
BranchOut(Option<String>),
Tags(Vec<TagChange>),
/// A palette color, or `None` to clear it.
Color(Option<ColorName>),
@@ -244,7 +246,7 @@ fn build(spec: &Spec, bang: bool, args: &[Option<&str>], sources: &Sources) -> R
Id::Link => Call::Link(node(text, &sources.nodes)?),
Id::Unlink => Call::Unlink(first.map(|query| node(query, &sources.nodes)).transpose()?),
Id::Portal => Call::Portal(text.to_string()),
Id::BranchOut => Call::BranchOut,
Id::BranchOut => Call::BranchOut(first.map(str::to_string)),
Id::Tags => Call::Tags(tag_changes(text)?),
Id::Color => Call::Color(color(text, &sources.colors)?),
Id::Style => Call::Style(style(text, &sources.styles)?),