This page covers what comes back when you open Caxton again: your windows through session restore, untitled documents that hold text, and after a crash the unsaved edits to a file, which the recovery journal records. It also covers Window ▸ Scratchpad, a document that saves itself and checks spelling, and how a save is written, as an in-place patch protected by a patch journal or as an atomic rewrite. Undo history, what Caxton does when another program changes, moves or deletes an open file, and where Caxton keeps its data are described here too.
What comes back
- An untitled document that holds text comes back after a normal quit and after a crash, still untitled, with no question asked. Untitled documents has the details.
- Unsaved edits to a file come back after a crash, when the next launch offers to restore them. At a normal quit Caxton asks whether to save them. Crash recovery has the details.
- The Scratchpad saves itself, and typing that no save had taken yet comes back after a crash. The Scratchpad has the details.
- Your windows come back after a normal quit with the same files, open modes and scroll positions. Session restore has the details.
Caxton records an untitled document two seconds after you stop typing, and a file's unsaved edits every 30 seconds. A crash can cost the typing since the last record.
Session restore
Quit with windows open and they come back on the next launch: same files, same open modes, same scroll positions (when the file hasn't changed underneath). Bookmarks and markers restore with them.
Untitled documents
Quitting no longer asks about an untitled document that holds text. Caxton keeps its text on disk between launches, in ~/Library/Application Support/Caxton/untitled/, and the document comes back at the next launch, still untitled and still unsaved, under the same title and in the same place among your windows and tabs. Its undo history starts empty. A new document that holds nothing but spaces, tabs and line breaks is not kept.
While the text is being written, the window shows Caxton is writing this document to disk, so that it is here the next time you open Caxton. The write is the same atomic save a file gets, and the quit waits for it. If it fails, the text goes to the recovery journal instead and at the next launch you see Caxton could not write this document to disk when it quit, so it recovered your text from the recovery journal. If the journal cannot take it either, Caxton does not quit, and the window states the cause.
Closing the window or the tab of an untitled document still asks, because that is a deliberate goodbye. Save asks where, and Don't Save removes the kept file. A kept file that no window, session or recovery journal refers to any more is removed at a launch once it is 7 days old.
Crash recovery
Every 30 seconds, documents with unsaved edits write a recovery journal: a compact sidecar describing the pending edits, never touching your original file. After a crash, the next launch offers to replay those edits before anything else opens (Restore unsaved changes?, with Restore and Discard). When the file changed on disk after the edits were recorded, the question becomes Restore unsaved changes to a file that has changed? and Discard is the default, with Restore Anyway beside it. A clean save or close discards the journal. If the file a journal belongs to has moved, the launch offers Locate…, Discard, or Decide Later; nothing is deleted on its own.
A replay checks the bytes around each edit before it applies it, and tells you when it could not finish:
- Some recovered edits couldn't be restored: the file no longer matches where some edits would apply, so those were skipped and the rest replayed. Nothing has been written to disk; review the document before you save.
- Recovered edits were not applied: the file opened read-only, so nothing was replayed. The recovery data is kept and offered again at the next launch; open the file writable to restore it now.
An untitled document writes its journal two seconds after you stop typing, and it comes back after a crash without the question: its window shows Caxton closed unexpectedly, and this document was recovered. A file on disk keeps the question. A recovered untitled document is still called “Untitled” and saving it always asks where, and the name of its backing file never shows. If two launches in a row fail while restoring the previous session, Caxton offers to start without restoring. After Start Without Restoring Caxton opens empty. The files of that session are not changed and are not reopened by themselves, so open them again from File ▸ Open Recent. The untitled documents Caxton kept stay closed with the rest, and they come back at the next normal launch.
A recovery journal holds up to 50 MB of unsaved changes per document. Past that, the journal pauses, Caxton asks you to save soon, and the journal keeps what it already holds. The status bar shows a Recovery Paused badge until the journal writes again, which a save brings about. A normal quit keeps an untitled document of any size, so only crash recovery has this limit.
The Scratchpad
Window ▸ Scratchpad (⌥⌘N) opens one document that is always there for notes, pasted text and half-finished thoughts. There is one Scratchpad per user and one window for it: the command brings that window forward when it is already open. Its text lives in ~/Library/Application Support/Caxton/scratchpad.txt, a plain UTF-8 file that Caxton makes the first time you open the Scratchpad, and the Inspector names the folder in its Kept in row.
- It saves itself two seconds after you stop typing, when you switch to another app, when you close its window and when you quit Caxton. Each save writes the new file beside the old one and swaps it in. The Scratchpad never asks to be saved and never shows the unsaved dot, and the Inspector's Edits row reads
Saved automatically. - ⌘S answers. File ▸ Save answers The Scratchpad saves itself. and saves at once.
- Save As writes a copy. The panel reads Saves a copy. The Scratchpad stays where it is. The copy opens as an ordinary document, and the Scratchpad stays open on its own file.
- It is editable on Caxton Free at any size.
- It stays out of Open Recent and out of Reopen Closed Tab. Window ▸ Scratchpad is how it comes back, and a session that had it open restores it in its tab group. Opening
scratchpad.txtthrough File ▸ Open goes to the same window, never to a second one. - It is always UTF-8. Reopen with Encoding, Save with Encoding and the byte order mark commands leave it alone, and File ▸ Revert to Saved is off, since it has no unsaved version to go back from.
When another app changes the file, the Scratchpad reloads it with the message The Scratchpad changed on disk, so Caxton reloaded it. If you had typing that no save had taken yet, it asks instead, under the heading The Scratchpad changed on disk while you were typing. Keep What I Typed saves your version over the other one, Reload takes the other version, and Compare… shows the two side by side first. If the file is deleted or moved away, Caxton writes it again from the window. If a save fails, the banner gives the reason, Caxton tries again after the next change, and File ▸ Save As keeps a copy in the meantime. After a crash the typing that was not yet saved comes back with no question, and the window displays Caxton restored the Scratchpad's unsaved typing after it quit unexpectedly.
A Scratchpad file that is not UTF-8 text, that cannot be read, or that has a folder in its place is left exactly as it is, and an alert explains why the Scratchpad cannot open.
Spell check
The Scratchpad checks spelling with the Mac's own checker, and it is the only window that does. A misspelled word gets a row of red dots under it. Right-click the word for up to eight suggestions, or No Guesses Found when the checker has none. Choosing a suggestion replaces the word as one undo step. Ignore Spelling accepts the word until Caxton quits, and Learn Spelling adds it to the Mac's own dictionary. Check Spelling While Typing, at the foot of the same menu, turns the check on or off and is remembered. It is on to begin with. A line longer than 16 KB is not checked, since it is data and not prose.
The Scratchpad marks a misspelled word with a row of red dots.
Safe saving
- In-place saves (tried first): when every edit keeps its byte length, such as a replace with text of the same size, there are fewer than 1,000 edited regions, none larger than 8 MB, and the file is on a local volume, Caxton patches just those bytes in the file. In-place saves are protected by a patch journal. If the save is interrupted, the next launch checks the file against the journal. A file left partly written offers Restore, which rolls it back to the last fully saved content, or Keep As-Is. A file that changed since in some other way asks Previous save may have been interrupted, with Skip Restore as the default and Restore Anyway, so a newer change is not overwritten.
- Atomic saves (everything else, including any edit that adds or removes bytes, files converted from another encoding, and files on network volumes): the new version is written alongside and swapped in one filesystem operation. There is no moment where the original is half-written.
If the rollback itself cannot be written, for example because the file is read-only or the disk is failing, Caxton alerts you (Couldn't restore “file”), keeps the journal, and offers the rollback again at the next launch. A save that fails for any other reason, such as a full disk or a folder you cannot write to, names the cause (Couldn't save “file”) and leaves the window and your edits as they were. A new document needs a small backing file in Caxton's storage so its edits can be recovered; when that file cannot be created, Couldn't create a new document gives the reason.
Undo
Undo history lives with the document and is limited by memory rather than by a count. An edit of 100 MB or more keeps its bytes in a temporary file on disk instead of in memory, and when macOS runs short of memory, undo history moves to disk off the main thread, so the window keeps responding. If a saved edit's bytes cannot be read back, for example because the temporary file is gone, Undo reports that it could not read the edit and changes nothing, instead of doing nothing silently. When an operation is too large to keep at all, Caxton applies it with a notice that the step cannot be undone. More in How Caxton Works.
External changes
Caxton watches open files. When another process rewrites a file you haven't edited, the document reloads in place; if you have unsaved edits, Caxton tells you instead of clobbering either side, and offers to compare the two versions before you choose. Keep Mine covers that one change: a later external write asks again. A file that is deleted, renamed, or unmounted is reported in every mode. When a rename or move is followed, the document adopts the new path: the title, the session, Open Recent and the bookmark and marker sidecars name it, and Save writes there. A file moved to the Trash is treated as missing: the document stays in memory, and Save offers Save As instead of writing into the Trash. A tail window stays on the path it opened, so a rotated log is picked up by the rotation prompt and Follow New File, and its bookmarks and markers are copied to the new path as well. Appends absorb incrementally; see follow-tail.
Where Caxton keeps its data
Everything lives in the app's own folders under ~/Library: recovery journals, bookmark and marker sidecars (incident notes ride in the bookmark sidecar and are written within seconds of a change), session state (including a Timestamp Format choice), and saved filter presets. Nothing is written next to your files, and nothing leaves your machine; see the privacy policy.
The Scratchpad's text is in ~/Library/Application Support/Caxton/scratchpad.txt and the text of untitled documents in ~/Library/Application Support/Caxton/untitled/. Temporary files (undo spills, disk-backed indexes, working copies of converted files) live in ~/Library/Application Support/Caxton/scratch/. Caxton removes the ones a crashed copy left behind at the next launch. A second copy of Caxton running at the same time leaves the first copy's files alone.