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

Re: PATCH: Polite output from traps with zle active

On Nov 2, 11:20am, Peter Stephenson wrote:
} Subject: PATCH: Polite output from traps with zle active
} TRAPUSR1() {
}   zle -I
}   print Hello, I am output
}   zle -R
} }
} It's possible there are extra safeguards I should have added but missed.
} If anyone thinks this should be done a different way, now would be a good
} time to mention it.

It's too bad that the trap writer has to call `zle -R' as well as `zle -I'.
What happens if you accidentally call only `zle -I'?

I can see how the zsh trap handler can't possibly know in advance whether
the user-defined trap will produce output, and therefore shouldn't do a
trashzle() on its own -- but surely it could detect whether zle has been
trashed and do the zrefresh() automatically?

If there really is some valid use for trashing zle without refreshing it,
perhaps another parameter to `zle -I' (or even something like `zle +I')
could be used to suppress the eventual zrefresh().

} It alters zle -R to allow it to be called when zle is not active ---
} it simply returns zero --- and adds `zle -I' (invalidate), which
} simply calls trashzle(). Both are allowed when zle is not active (and
} do nothing) because there is no good reason for forcing the onus of
} deciding whether the display needs to be cleared and refreshed onto
} the writer of the trap function.

It'd also be nice if `zle -R' and `zle -I' returned zero when zle is
active and nonzero otherwise, just as `zle' with no arguments does.
There may not be much use for this, since probably one most often wants
to test for zle *before* invalidating it, but there is some benefit to

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

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