synchrony / smsn-mode

Emacs client for Semantic Synchrony knowledge graphs
GNU General Public License v3.0
11 stars 6 forks source link

selective visibility and motion within trees #2

Open joshsh opened 8 years ago

joshsh commented 8 years ago

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 commented 8 years ago

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:

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

JeffreyBenjaminBrown commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

How can I see that?

joshsh commented 8 years ago

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 commented 8 years ago

Nice!