Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selective visibility and motion within trees #2

Open
joshsh opened this issue Aug 1, 2016 · 6 comments
Open

selective visibility and motion within trees #2

joshsh opened this issue Aug 1, 2016 · 6 comments

Comments

@joshsh
Copy link
Member

joshsh commented Aug 1, 2016

Brain-mode exposes tree-shaped views of a graph of "atoms" or notes. These can be edited in place and pushed back to the graph.

Currently, a view is a pre-order traversal from a given root with indentation for depth, up to a certain maximum depth. If one atom at a given depth is visible, so are all atoms at that depth.

This approach works well for an overall hierarchical view of the descendants of a node, but may not be ideal for navigation. It has been suggested that atoms should be selectively expanded and collapsed, up to any depth.

The main challenge for implementation is to encode the state of the atoms in the view (expanded/collapsed) when pushing the view into the graph, and to preserve it in the updated view which is returned.

@JeffreyBenjaminBrown
Copy link
Member

Emacs could be displaying the same node on multiple lines. The nodes ought therefore it seems to be in some kind of sequence ... or a set of pairs (Int, Node) where no two Ints are the same ... or a map from Int to Node ...

Within that collection, each Node it seems could usefully include:

  • its address
  • its text
  • its parent
  • its next and previous sibling
  • whether it is folded
    • showing-contents might be a safer name than folded, to avoid conflict with later fold features in the sense of collapsing a branch to a summary statistic

Is it a task that can be done by rewriting brain-mode alone (and not smsn too)?

@JeffreyBenjaminBrown
Copy link
Member

JSON or text is good for transfer between programs, e.g. brain-mode and smsn. Within a program, though, it seems helpful to use a more explicitly structured representation -- nodes or nodes-in-view. A node-in-view has properties like whether it is folded, and the (address of the) node represented there. (Earlier I suggested foldedness is a property of a node, but it's not; foldedness is only meaningful in the context of a view.)

@joshsh
Copy link
Member Author

joshsh commented Aug 1, 2016

Have a look at the JSON which is sent back to Brain-mode from the server. That's a generic tree structure which is probably what you are looking for (only without a foldedness property at present).

@JeffreyBenjaminBrown
Copy link
Member

How can I see that?

@joshsh
Copy link
Member Author

joshsh commented Aug 1, 2016

You can add a debug message, e.g.

(defun receive-view-internal (status context)
  (let ((json (json-read-from-string (strip-http-headers (buffer-string))))
      (editable (is-readwrite-context context)))
    (debug-message (concat "received JSON: " (json-encode json)))
   ...

Then look in *Messages*.

@JeffreyBenjaminBrown
Copy link
Member

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants