Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: edit-command-line: disable `monitor' option locally



On Mar 17, 11:08am, Frank Terbeck wrote:
}
} Here is how to get the error:
} 
} a) Start a new shell. The error seems to only appear the first time the
}    `edit-command-line' widget is called.
} b) Enter something into the command line buffer.
} c) Strike your `edit-command-line' shortcut.
} d) "C-z" to suspend.
} e) Run another command while being suspended.
} f) "fg" to get the editor back.
} g) Exit the editor.

Nope, still nothing.  Even starting zsh with a ZDOTDIR pointing at a
file that does nothing but set up edit-command-line, I cannot make
this happen (with 4.3.11-dev-1 patchlevel 1.5223).

} > On the other hand if I put in this patch, then when I try to resume the
} > backgrounded editor
} 
} Um. How do you end up with a backgrounded editor with this patch?
} Shouldn't it be impossible to background the editor if `monitor' is
} unset? I can't seem to get that to happen on my linux-based laptop.

Here's with edit-command-line straight out of the distribution -- the
blank line is where I hit ^Z in the editor:

torch% echo something

zsh: suspended  
torch% echo something
torch% echo something

Now I hit enter and go on:

something
torch% jobs
[1]  + suspended  
torch% 

At this point I can bring vim back into the foreground with no trouble.
It's true the command line will be lost if I don't force vim to save it
somewhere, because the file has already been removed, the contents are
only in vim's working copy.

Now here's how it differs with your patch applied:

torch% echo otherthing

torch% echo otherthing
otherthing
torch% jobs
[1]  + suspended  
torch% 

I.e. the only thing that changed was whether I got notified about the
job being suspended.  Vim still handled the ^Z and stopped itself.
But bad things happen if I try to bring it back into the foreground
because zsh doesn't send CONT to the correct process group (I think
is what's going on, but I can't be sure).

} In any case, I think the widget should protect the user from losing the
} command line. And disallowing the editor from backgrounding should do
} that (and in fact does for me).

I agree but don't think twaddling no_monitor is sufficient.  If you
remove no_monitor but add xtrace to the setopts in edit-command-line,
what do you see after you hit ^Z in vim?  I get this:

----
torch% echo foo+edit-command-line:2> local 'tmpfile=/tmp/zshecl26567'
+edit-command-line:3> print -R - 'echo foo'
+edit-command-line:5> vi /tmp/zshecl26567


zsh: suspended  
torch% echo foo+edit-command-line:6> print -Rz - 'echo foo'
+edit-command-line:7> rm -f /tmp/zshecl26567
+edit-command-line:8> zle send-break

torch% echo foo
----

I suspect that in your case the entire edit-command-line function is
stopped, so rm -f / zle send-break never happens until after you bring
it into the foreground again, but I don't know why it differs for me.



Messages sorted by: Reverse Date, Date, Thread, Author