!7 sS snippetID = #1008122; sS editorCommand = "jedit"; File tempFile; p { tempFile = getProgramFile(fsI(snippetID) + ".javax"); S text = loadSnippet(snippetID); saveTextFile(tempFile, text); long lastMod = file.modified(); nohup(editorCommand + " " + platformQuote(tempFile)); repeat with ms sleep 100 { long mod = file.modified(); if (mod != lastMod) { long newMod = mod; int mods = 0; do { sleep(100); newMod = file.modified(); ++mods; } while (newMod != mod); if (mods > 1) warn("Editor doesn't save atomically. Mod count: " + mods); newText = loadTextFile(tempFile); if (neq(text, newText)) { print("EDITING " + snippetID + " (" + l(text) + " -> " + l(newText) + " chars)"); text = newText; editSnippet(snippetID, text); print("EDITED."); } mod = newMod; } } }