magit / with-editor

Use the Emacsclient as the $EDITOR of child processes
http://magit.vc/manual/with-editor
GNU General Public License v3.0
185 stars 44 forks source link

Can we make this delay configurable? #130

Closed ackerleytng closed 2 weeks ago

ackerleytng commented 2 months ago

If I understand correctly, now with-editor-export-editor tries to read everything as the shell starts up for 0.1s.

https://github.com/magit/with-editor/blob/322ee26d3a7d3d67840293041837b7e70cffa8d1/lisp/with-editor.el#L746

My shell takes a little long to start up (sometimes), so the export ends up writing something broken to the shell. Setting this to 0.2 seems to work more reliably for me.

Can we make this configurable?

tarsius commented 2 months ago

The whole accept-process-output business seems a bit questionable and blaming/tracing history didn't reveal any explanations.

I probably won't get around to this for a few weeks, can you just patch this locally until then?

Actually, please also give (while (accept-process-output process 0.1 nil t)) a try.

ackerleytng commented 2 months ago

(while (accept-process-output process 0.1 nil t)) seems to work too. I'll report back if there are more issues.

ackerleytng commented 2 months ago

It only works sometimes. I think (while (accept-process-output process 0.2)) works more reliably.

ackerleytng commented 2 months ago

I think we might need perhaps something more reliable than a timeout? If I understand correctly the purpose of this is to wait for the prompt to be ready and then export EDITOR to the shell. If this understanding is right, I could try to figure out some solution :)

Here's what I'm seeing, even though I've increased the timeout to 0.5

 export EDITOR="/usr/bin/emacsclient --socket-name=/run/user/1048788/emacs/server"
clear

^[[?1;2c
ackerleytng@ackerleytng-machine ~
❯ 1;2c
tarsius commented 2 months ago

I have to create releases and just doing one more thing first "just one more time", isn't going to help. I'll look into this later. I am referring you back to

I probably won't get around to this for a few weeks, can you just patch this locally until then?

ackerleytng commented 2 months ago

Thanks so much, no hurry on this at all!

tarsius commented 2 weeks ago

I've bumped it up to a full second.