zsh-workers
 help / color / mirror / code / Atom feed
* zle debugging
@ 2013-03-05  3:55 joe M
  2013-03-05  5:44 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: joe M @ 2013-03-05  3:55 UTC (permalink / raw)
  To: zsh-workers

Hello,

I am wondering if there is a way to debug zle widgets.

I realize that setopt xtrace and verbose do not help with the widgets.
Other than littering the code with zle -M lines, is there a mechanism
to debug zle widgets?

Any thoughts, please?

Thanks
Joe


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: zle debugging
  2013-03-05  3:55 zle debugging joe M
@ 2013-03-05  5:44 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2013-03-05  5:44 UTC (permalink / raw)
  To: zsh-workers

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?).


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-05  5:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-05  3:55 zle debugging joe M
2013-03-05  5:44 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).