The Scratchfile (CAN)¶
Backlinks¶
- CAN should fire a SCRATCHFILE_ERROR event if unsupported syntax is found
- CAN should parse the scratchfile when it is updated. If CAN hits an error in the scratchfile or finds unsupported syntax (CAN uses a subset of markdown), it should fire a SCRATCHFILE_ERROR event with the error passed as an argument. To allow other parts of the software to respond.
- CAN should parse the scratchfile when it is updated
- In order to be able to store notes and use content-addressable storage, CAN needs to have access to the note's content. Because of this, CAN should parse the scratchfile whenever it is updated (CAN should fire a SCRATCHFILE_UPDATED event when the scratchfile is updated). Once the AST has been constructed, CAN should ignore 'beneath the fold'.
- CAN should fire a SCRATCHFILE_PARSED event when the scratchfile is parsed
- CAN should parse the scratchfile once it has been updated. Once CAN has successfully parsed the scratchfile, the SCRATCHFILE_PARSED event should be fired, with the AST included as an argument. To allow other parts of the software to respond.
- The CAN store's current scratchfile address field holds the address of everything above-the-fold in the scratchfile
- The CAN state-store currentscratchfileaddress field holds the last-updated address of everything above the fold in the scratchfile
- The CAN store's current scratchfile new field holds if the current scratchfile exists in the notebook
- The CAN's current scratchfile new holds if the current scratchfile is currently a note within the notebook.
- CAN should fire a SCRATCHFILE_FOUND event when an existing scratchfile is found
- CAN may look for existing scratchfiles at different stages in the future. When one is found, a SCRATCHFILE_FOUND event should be fired, with the path of the scratchfile as an argument.
- CAN's watch-scratchfile handler should listen to the SCRATCHFILE_FOUND event
- So all scratchfiles found by CAN are watched for changes, the watch scratchfile handler should listen to the SCRATCHFILE_FOUND event.
- CAN should fire a SCRATCHFILE_UPDATED event when the scratchfile is updated
- When a scratchfile is created CAN should start to watch it. When CAN detects a change in the scratchfile, a SCRATCHFILE_UPDATED event should be emitted.
- CAN should ignore 'beneath the fold'
- CAN's scratchfiles may have a marker (
---
) called the fold. Anything beneath this point should be ignored by can. This gives the user space to keep short-lived working drafts while they explore their notes.
- CAN's scratchfiles may have a marker (
- CANs note-existence handler should listen for SCRATCHFILE_ADDRESSED
- So CAN can learn if the scratchfile contains a new note. The note-existence handler should listen to the SCRATCHFILE_ADDRESSED event. Once recieved, the handler should check if a note at this address exists in the notebook. CAN's note-existence handler should fire NOTE_EXISTENCE when it determines if a note exists.
- CAN's create-note handler should listen for COMMAND_ADD
- CAN's create-note handler is intended to add a new note at the note's address using the current state of the scratchfile to determine which note is added.
- When a CAN scratchfile is addressed, check to see if the note is new
- This helps CAN decide what to tell the user; and how commands should respond based on context. CAN should have a single state store which can be queried about the latest state of the scratchfile. Commands won't be able to respond to CAN events so state becomes necessary at this point.
- CAN's scratch command should fire the COMMAND_SCRATCH event
- When a CAN user sends a scratch command, the COMMAND_SCRATCH event should be fired to allow handlers to respond. This should include whether the scratchfile exists as a boolean argument.
- CAN's edit command should load the named note into the scratchfile
- When a valid note name is passed to the edit command, the named note should be loaded for editing into the scratchfile.
- CAN's scratch command should push existing scratchfile content below the fold
- Running CAN's scratch command while a scratchfile exists should push all existing content beneath a new fold. This is done by adding
---
to the top of the scratchfile.
- Running CAN's scratch command while a scratchfile exists should push all existing content beneath a new fold. This is done by adding
- CAN should begin watching an existing scratchfile on startup
- To avoid the user having to remove and recreate the scratchfile for each session of CAN, CAN should check for and watch an existing scratchfile at startup time.