I run a lot of commands from TextMate, and sometimes they can take a long time to finish. The usual “execute line” command doesn’t return until the execution is complete, so the document (and TM as a whole) is unresponsive while waiting. I can run them in the background, but then I need a way to insert the output into the original document. My current workaround is to bring the document forward using 'mate', but that means whenever output is ready, the doc jumps into the foreground, interrupting anything else I may have been doing.
I don’t know of a way to do this, but it would be great if I could send text to a document without giving it focus… e.g. something like: echo "some output" | mate --no-focus --uuid $DOC
-David
On 27 Sep 2016, at 7:35, David Green wrote:
I run a lot of commands from TextMate, and sometimes they can take a long time to finish. The usual “execute line” command doesn’t return until the execution is complete, so the document (and TM as a whole) is unresponsive while waiting. I can run them in the background, but then I need a way to insert the output into the original document. My current workaround is to bring the document forward using 'mate', but that means whenever output is ready, the doc jumps into the foreground, interrupting anything else I may have been doing.
Is the issue that it locks the entire application? E.g. if running a (slow) command only blocked the document for which we are waiting for results, would that solve the problem?
I don’t know of a way to do this, but it would be great if I could send text to a document without giving it focus… e.g. something like: echo "some output" | mate --no-focus --uuid $DOC
I assume you need this to also work for untitled documents, otherwise simply updating the file on disk should work.
On Sep. 26, 2016, at 11:48 pm, Allan Odgaard mailinglist@textmate.org wrote:
Is the issue that it locks the entire application? E.g. if running a (slow) command only blocked the document for which we are waiting for results, would that solve the problem?
That would help, although sometimes I want to be able to continue working on the same document.
I assume you need this to also work for untitled documents, otherwise simply updating the file on disk should work.
Right. I’ve been thinking of trying that (save the document, figure out the cursor position, insert the results at that point in the file). One downside is that it means saving untitled or changed docs even if I didn’t want to save them… but in practice, maybe this doesn’t matter much. (How often do I really care about the previously-saved state? And I could always create some sort of backup copies.) I could even save new documents to a specific dir somewhere.
The other downside is that TextMate doesn’t update changed files when it is not in the foreground. It’s useful to see the progress of a command while it runs. Presumably that is a matter of performance, to keep TM well-behaved when it’s in the background. If it could occasionally update itself, every few seconds or even less often, that would be more than good enough for casual monitoring.
-David
On 27 Sep 2016, at 9:18, David Green wrote:
On Sep. 26, 2016, at 11:48 pm, Allan Odgaard mailinglist@textmate.org wrote:
Is the issue that it locks the entire application? E.g. if running a (slow) command only blocked the document for which we are waiting for results, would that solve the problem?
That would help, although sometimes I want to be able to continue working on the same document.
Can you give an example of what type of commands you’re running? Just so I better understand the workflow.
[…] The other downside is that TextMate doesn’t update changed files when it is not in the foreground. It’s useful to see the progress of a command while it runs. Presumably that is a matter of performance, to keep TM well-behaved when it’s in the background.
Correct, for example when people do `git rebase …` the document may see a lot of updates, and we do not want to reload all of them, especially not if the user has local changes (as we may then get merge conflicts on each update).
But completely suppressing updates might be too pessimistic, so I’ll look into having it update e.g. 3 seconds after last change. I want to do similar for SCM, where we also suppress updates when TextMate is in the background, but that does bother me a bit (as I’d prefer to see the file browser update, as I commit files from the terminal etc.).
On Oct. 10, 2016, at 8:46 am, Allan Odgaard mailinglist@textmate.org wrote:
Can you give an example of what type of commands you’re running? Just so I better understand the workflow.
The original and main motivation is running SQL queries, but think of anything shell/command-line/REPL… basically, a non-blocking ^R. Running a SQL shell like psql in a terminal can be painful because the tabular results are usually too long to fit across the screen and get garbled by wrapping; or because there’s a lot of trial and error and “good” output is mixed with the “bad”.
Running the queries in TextMate is vastly more pleasant. Longs rows don’t matter because I can scroll horizontally, and if I don’t like the results I can simply undo the output and try again. And I can edit the output and/or use it for subsequent commands. When I’m troubleshooting a problem, I can run different queries until I track down the problem, and just keep a record of the useful steps and output. I can even save a file with the commands I ran to be used later. When I have a similar task, I can run those steps again, changing or adding or re-ordering the steps as I go.
Most of the time, the commands execute quickly. Sometimes, especially with SQL, they can take a while, and I will edit some other file while I wait. Or I’ll continue working in the same file (e.g. preparing the next steps, or maybe trying to rewrite the long query to make it perform better the next time I run it).
Of course, with that setup in place, I can run all sorts of other shell commands — it’s obviously not a complete replacement, and some things are still better done in a real terminal. But I’ve ended up using my text editor more than the terminal for everyday work. Compiling or running unit tests are other examples of longer-running processes where it’s nice to be able to monitor the output in the background.
-David
On Oct. 10, 2016, at 8:46 am, Allan Odgaard mailinglist@textmate.org wrote:
But completely suppressing updates might be too pessimistic, so I’ll look into having it update e.g. 3 seconds after last change. I want to do similar for SCM, where we also suppress updates when TextMate is in the background, but that does bother me a bit
That sounds quite reasonable.
I’m currently trying an approach that uses the 'application.did-activate’ callback to check for updates and insert them. (There isn’t a “document.did-activate”, is there?) When a doc that isn’t frontmost gets an update, I switch away from TextMate and then back again, triggering the callback. The momentary interruption isn’t too bad; sometimes it isn’t even noticeable, although it seems that keystrokes can get mixed up if I’m in the middle of typing quickly.
I was trying to think of a way to use the new auto-refreshing, but there would have to be a way to trigger it, e.g. mate --uuid $doc --event foobar that would set $TM_REFRESH to “foobar” and run any commands accordingly.
-David