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

Re: zle debugging



On Mar 4, 10:55pm, joe M wrote:
} 
} I realize that setopt xtrace and verbose do not help with the widgets.

Of course they do.  You just have to direct stderr somewhere other than
the screen.

Suppose you have a widget you normally define like this:

    _buggy() {
      zle beep
      : other broken stuff
    }
    zle -N _buggy

You can put a wrapper widget around it like so:

    _debug_buggy() {
       {
         setopt localoptions xtrace
	 _buggy "$@"
       } 2>>| ${TMPPREFIX}_buggy$$
    }
    zle -N _buggy _debug_buggy

Now each time you invoke the binding for _buggy, you'll get output
appended to the temp file.  If you stick to the convention of naming
your functions and widgets the same, you can make it generic:

    _debug_widget() {
       {
         setopt localoptions xtrace
	 $WIDGET "$@"
       } 2>>| ${TMPPREFIX}${WIDGET}$$
    }
    zle -N _buggy _debug_widget
    zle -N _other _debug_widget

For a more extensive example of this sort of thing, see _complete_debug
(bound by default to ^X?).



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