zsh-users
 help / color / mirror / code / Atom feed
* Line numbers and debugging verbosity
@ 2018-04-09  5:19 Bart Schaefer
  2018-04-09 15:51 ` Ray Andrews
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Schaefer @ 2018-04-09  5:19 UTC (permalink / raw)
  To: Zsh Users

On Fri, Apr 6, 2018 at 9:29 AM, Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> What I'm actually trying to do is reduce verbosity of a function by
> redefining various message printer functions as null.  It works fine with
> functions, but if the message printers are aliases (which seem to be the
> only way to get:  ${(%):-%x %I} ... line information printed, it seems that
> can't be done in a function) ... then it goes sour.

On Sun, Apr 8, 2018 at 3:38 PM, Ray Andrews <rayandrews@eastlink.ca> wrote:
>
> Is there a new strategy that might work?  Nullify the function and/or the
> alias?  Really, just some way of stopping messages from printing at all?

There are several possible approaches.  For one, you could stop using
your own "echo"/"print" statements and instead turn tracing on and off
for the surrounding function:

  functions -T test1

If you want to keep printing your own messages instead of using the
xtrace facility, let's get you away from aliases.  The information for
%x and %l are in the $funcfiletrace variable, and will give you the
result you want from inside a function.

  warningmsg() {
    print -n "${funcfiletrace[1]}: " && magline "$*"
  }

For another approach, you had a perfectly good example:

>     [[ "$vverbose" < 3 ]] &&
>     {
>         warningmsg () { ; }
>      }

Just put a similar test in the definition of "warningmsg" e.g.

  warningmsg() {
    (( $dbg )) &&
    print -nr - "${funcfiletrace[1]}: " && magline "$*"
  }

Now you don't have to modify the function, you just assign dbg=1 or dbg=0.


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

end of thread, other threads:[~2018-04-09 15:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-09  5:19 Line numbers and debugging verbosity Bart Schaefer
2018-04-09 15:51 ` Ray Andrews

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